output compare : coded impulsions generation

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
User avatar
alex31
Posts: 445
Joined: Fri May 25, 2012 10:23 am
Has thanked: 57 times
Been thanked: 88 times

output compare : coded impulsions generation

Post by alex31 »

Hello.

I want to generate a train of impulsions with precise timing, bit 'true' is coded by a 0,45µs wide positive pulse, separated by 1µs.
Is there pattern for GPT for that use case ?
but it seems to me that GPT is so much oriented callback : i will need to set pin output level in the callback,
adding a lot jitter.

So the question is : is there a way to do that with chibios api, or do i have to write a specific driver above timer, perhaps even
using dma to precalculate a timing buffer with duration of each level before transition.

Thanks
Alexandre
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: output compare : coded impulsions generation

Post by Giovanni »

You coud use DMA triggered by a GPT for things like that, the problem is that DMA would write on an entire port. Another potential candidate is the SPI driver, you could generate the signal on the MOSI pin.

Giovanni
User avatar
alex31
Posts: 445
Joined: Fri May 25, 2012 10:23 am
Has thanked: 57 times
Been thanked: 88 times

Re: output compare : coded impulsions generation

Post by alex31 »

Another potential candidate is the SPI driver, you could generate the signal on the MOSI pin.


At first, i didn't see how to use the spi since the signal I want to generate is asymetrical, but then i understand your idea that one pulse can be
generated by a train of spi bits, so that positive pulse can have different length than negative one.

And it works (i had very infrequent glitches that i have eliminated raising DMA priority)

thanks for the tips !


ps: another solution would have been to use pwm and change output pin mode to output in reset callback when i don't want pulse, but even using fast tailored isr, it works only at 50% of the speed i need to achieve (1µs between 0,45µs pulses)
spi timing is not as acurate as pwm, but that will suffice.

Alexandre
Post Reply