dig:mic-servo
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dig:mic-servo [2011/03/22 14:56] – tobi | dig:mic-servo [2024/02/29 07:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 62: | Line 62: | ||
# define EXAMPLE_TC_IRQ_GROUP | # define EXAMPLE_TC_IRQ_GROUP | ||
# define EXAMPLE_TC_IRQ | # define EXAMPLE_TC_IRQ | ||
- | # define FPBA FOSC0 // chosen PBA clock frequency - set up to be same as cystral freq=12MHz | ||
#define FADC 10000 // desired ADC sample rate in Hz | #define FADC 10000 // desired ADC sample rate in Hz | ||
#define TC_CHANNEL | #define TC_CHANNEL | ||
Line 104: | Line 103: | ||
#define FOSC0 | #define FOSC0 | ||
+ | #define FPBA (FOSC0*11/ | ||
+ | |||
#define OSC0_STARTUP | #define OSC0_STARTUP | ||
void init_clock() { | void init_clock() { | ||
Line 456: | Line 457: | ||
.burst | .burst | ||
.clki = FALSE, | .clki = FALSE, | ||
- | .tcclks | + | .tcclks |
}; | }; | ||
Line 485: | Line 486: | ||
// Set the compare triggers for timer/ | // Set the compare triggers for timer/ | ||
- | // TC counter is 16-bits, with secondary main clock fPBA = 12 MHz. | + | // TC counter is 16-bits, with secondary main clock TIMER_CLOCK2 |
- | // Lowest possible freq is 12e6/2^16=183.1Hz. | + | // Lowest possible freq is 15.5MHz/(2^16)=236Hz. |
// We want ADC sample rate of FADC Hz. To get this, we load RC (Reset Counter) value so that | // We want ADC sample rate of FADC Hz. To get this, we load RC (Reset Counter) value so that | ||
- | // TC reaches RC value every 1/ | + | // TC reaches RC value every 1/ |
- | // E.g., to get FADC=10kHz, we need RC=12e6/10000=1200. | + | // E.g., to get FADC=10kHz, we need RC=15.5MHz/10000=1550. |
+ | // The timer interrupt will then run at 10kHz (verfied on scope). | ||
+ | // The timer interrupt for debug will toggle PA10 which will result in a square wave at 5kHz (verified). | ||
tc_write_rc(tc, | tc_write_rc(tc, | ||
dig/mic-servo.txt · Last modified: 2024/02/29 07:28 by 127.0.0.1