Subversion Repositories svnkaklik

Rev

Rev 656 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 656 Rev 657
Line 43... Line 43...
43
   setup_comparator(NC_NC_NC_NC);
43
   setup_comparator(NC_NC_NC_NC);
44
   setup_vref(FALSE);
44
   setup_vref(FALSE);
45
   enable_interrupts(INT_TIMER0);
45
   enable_interrupts(INT_TIMER0);
46
   enable_interrupts(GLOBAL);
46
   enable_interrupts(GLOBAL);
47
   
47
   
48
   setup_adc_ports(AN0_TO_AN2|VSS_VDD);
48
   setup_adc_ports(AN0_TO_AN2|VSS_VREF);
49
   setup_adc(ADC_CLOCK_DIV_64);
49
   setup_adc(ADC_CLOCK_DIV_64);
50
 
50
 
51
   usb_init(); // initialise USB module
51
   usb_init(); // initialise USB module
52
 
52
 
53
   while (TRUE)
53
   while (TRUE)
54
   {
54
   {
55
   
55
   
56
   while(!usb_cdc_connected());
56
   while(!usb_cdc_connected());
-
 
57
   time=0;
57
   printf(usb_cdc_putc,"time[s]  x  xerr  y  yerr  z  zerr \nr");
58
   printf(usb_cdc_putc,"time[s]  X  Xerr  Y  Yerr  Z  Zerr \n\r");
58
 
59
 
59
   while(usb_cdc_connected())  // pockej nez se pripoji seriovy port PC
60
   while(usb_cdc_connected())  // pockej nez se pripoji seriovy port PC
60
   {
61
   {
61
      for(i=0; i <BUFLEN; i++)
62
      for(i=0; i <BUFLEN; i++)
62
      {
63
      {
63
         set_adc_channel(1);
64
         set_adc_channel(0);
64
         delay_us(10);
65
         delay_us(10);
65
         x[i]=read_adc();
66
         x[i]=read_adc();
66
         xavg+=x[i];
67
         xavg+=x[i];
67
         
68
         
68
         set_adc_channel(1);
69
         set_adc_channel(1);
69
         delay_us(10);
70
         delay_us(10);
70
         y[i]=read_adc();
71
         y[i]=read_adc();
71
         yavg+=y[i];
72
         yavg+=y[i];
72
 
73
 
73
         set_adc_channel(1);
74
         set_adc_channel(2);
74
         delay_us(10);
75
         delay_us(10);
75
         z[i]=read_adc();
76
         z[i]=read_adc();
76
         zavg+=z[i];
77
         zavg+=z[i];
77
      }
78
      }
78
      
79