Page 1 of 1

output compare : coded impulsions generation

Posted: Wed Jan 27, 2016 11:28 am
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

Re: output compare : coded impulsions generation

Posted: Wed Jan 27, 2016 11:33 am
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

Re: output compare : coded impulsions generation

Posted: Tue Feb 02, 2016 3:59 pm
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