Generate 30 Mhz Clock and an Interrupt on every nth Clock
Posted: Sat Aug 04, 2012 4:00 pm
Hi together,
I am quite new to Chibios and I am using it on an STM32F407-Discovery Board. I am tryping to feed a TLC5940 from the STM32, which is a 16 Channel LED-Driver. The HW is working as a simple loop trigers the TLC5940 correctly.
Now I am trying to setup ChibiOS so that the STM32 generates a 30 Mhz Clock Output to drive the Clock-Signal for the TLC5940. Additionaly I do need to call a interrupt routinge every 4096 clock cycles of the 30 Mhz-Signal to restart the Grayscale-PWM of the TLC5940. I can setup two GPT timers with 30 MHz. The first toggles the GPIO for generating the Clock-Signal, the second gets a 4096 counter and does the Grayscale-Restart. That looks like this:
But this seem to me very inefficient. Isn't there a way to use just on HW-Setup that directly put out 30Mhz (or something near to it) and calls an ISR every 4096 Clock-Cycles?
Thanks for any help
Mario
I am quite new to Chibios and I am using it on an STM32F407-Discovery Board. I am tryping to feed a TLC5940 from the STM32, which is a 16 Channel LED-Driver. The HW is working as a simple loop trigers the TLC5940 correctly.
Now I am trying to setup ChibiOS so that the STM32 generates a 30 Mhz Clock Output to drive the Clock-Signal for the TLC5940. Additionaly I do need to call a interrupt routinge every 4096 clock cycles of the 30 Mhz-Signal to restart the Grayscale-PWM of the TLC5940. I can setup two GPT timers with 30 MHz. The first toggles the GPIO for generating the Clock-Signal, the second gets a 4096 counter and does the Grayscale-Restart. That looks like this:
Code: Select all
static void gpt2cb(GPTDriver *gptp);
static const GPTConfig gpt2cfg = {
60000000, /* 60 MHz timer clock.*/
gpt2cb /* Timer callback.*/
};
static void gpt3cb(GPTDriver *gptp);
static const GPTConfig gpt3cfg = {
60000000, /* 60 MHz timer clock.*/
gpt3cb /* Timer callback.*/
};
gptStart(&GPTD2, &gpt2cfg);
gptStartContinuousI(&GPTD2, 2); // 1 as counter does not work, so I use 60 Mhz
gptStart(&GPTD3, &gpt3cfg);
gptStartContinuousI(&GPTD3, 8192);But this seem to me very inefficient. Isn't there a way to use just on HW-Setup that directly put out 30Mhz (or something near to it) and calls an ISR every 4096 Clock-Cycles?
Thanks for any help
Mario