Page 1 of 1

How to handle single pulse length with Chibios

Posted: Thu Sep 27, 2012 10:32 pm
Hi ALL!

I have question that i could not find the answer over the google.
The question is as in topic: How to handle single pulse length with Chibios?

From time to time there is a need to handle a single pulse length (there is such function in arduino) or as in attachment handling pulses with different length (where 0- short HIGH, 1- long HIGH but LOW have same length).

Thanks in advance!
Piotr Klimczak

Re: How to handle single pulse length with Chibios

Posted: Fri Sep 28, 2012 7:37 am
by Giovanni
Hi,

You can do this using a PWM driver: in the PWM channel callback you can change the output period (pwmChangePeriodI()) and the duty cycle (pwmEnableChannelI()), the change then occurs at the start of the next cycle.

Of course the problem is the PWM frequency, if it is too high you will saturate your CPU with interrupts.

An alternate solution is to use the MOSI signal of an SPI, prepare a buffer with your pattern then transmit is over SPI using DMA.

Measuring such a signal can be done using the ICU driver.

Giovanni