Line 44... |
Line 44... |
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_VREF); |
48 |
setup_adc_ports(AN0_TO_AN2|VSS_VREF); |
49 |
setup_adc(ADC_CLOCK_DIV_64); |
49 |
setup_adc(ADC_CLOCK_DIV_32); |
50 |
|
50 |
|
51 |
usb_init(); // initialise USB module |
51 |
usb_init(); // initialise USB module |
52 |
|
- |
|
53 |
while (TRUE) |
- |
|
54 |
{ |
- |
|
55 |
|
52 |
|
56 |
while(!usb_cdc_connected()); |
53 |
while(!usb_cdc_connected()); |
57 |
time=0; |
54 |
time=0; |
58 |
set_timer0(0); |
55 |
set_timer0(0); |
59 |
printf(usb_cdc_putc,"time[s] X Xerr Y Yerr Z Zerr \n\r"); |
56 |
printf(usb_cdc_putc,"time[s] X Xerr Y Yerr Z Zerr \n\r"); |
Line 83... |
Line 80... |
83 |
zavg=zavg/BUFLEN; |
80 |
zavg=zavg/BUFLEN; |
84 |
|
81 |
|
85 |
// odesli namerene hodnoty |
82 |
// odesli namerene hodnoty |
86 |
printf(usb_cdc_putc, "%7.3f %4.3f %4.3f %4.3f %4.3f %4.3f %4.3f \n\r",((time << 16) + get_timer0())/15625.0, xavg, quadraticerror(xavg,x,BUFLEN), yavg, quadraticerror(yavg,y,BUFLEN), zavg, quadraticerror(zavg,z,BUFLEN)); //konstanta k je kvuli prevodu do rozzumnych jednotek [s] |
83 |
printf(usb_cdc_putc, "%7.3f %4.3f %4.3f %4.3f %4.3f %4.3f %4.3f \n\r",((time << 16) + get_timer0())/15625.0, xavg, quadraticerror(xavg,x,BUFLEN), yavg, quadraticerror(yavg,y,BUFLEN), zavg, quadraticerror(zavg,z,BUFLEN)); //konstanta k je kvuli prevodu do rozzumnych jednotek [s] |
87 |
} |
84 |
} |
88 |
} |
- |
|
89 |
} |
85 |
} |