cancel
Showing results for 
Search instead for 
Did you mean: 

Using a Timer as a Divider

mb2
Associate II
Posted on January 25, 2012 at 10:13

Hi

Can somebody point me in the right direction. I have a peripheral that uses a strange SPI where the data is triggered on both rising and falling edge of the clock.

I have heard the i could use a timer as a divider and make an output that changes it state by triggering on the rising edge of an input pin, I have made an image of it.0690X0000060505QAA.png

I'm using a STM32f103c8.

Can somebody please help

#spi-timer
5 REPLIES 5
finnb2
Associate II
Posted on January 25, 2012 at 10:48

Hep Mikkel,

not sure, what it is you want, but why dont you use an external interrupt....

/Finn

mb2
Associate II
Posted on January 25, 2012 at 11:04

Hej Finn!

The problem whit an interupt is the delay(i have tried it already), i still use the SPI data pin, so the data is not aligned whit the new clock that i create in my interrupt routine.

Men ellers tak 🙂

Posted on January 25, 2012 at 13:58

No, not really, the timers aren't that efficient, you could try an external flip-flop? Getting the timer to do a divide by 2 might be possible, you'd feed the source clock in via an ETR pin, and get it out via a CHx pin. They'd probably be a lot of phase/delay.

Other that that consider bit-doubling the data you want to send, so instead of transmitting 8-bits, send 16-bits. ie 01010101 -> 0011001100110011

You could extract data in a similar manner.

Not sure if that achieves what you need.

You could also just bit-bang the GPIOs directly.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mb2
Associate II
Posted on January 25, 2012 at 14:36

Ok but after reading a bit i still think it is possible what if i use a counter that has a external clock source, eg the SPI clock and connect i back ind to the processor to a TIM etr, then make a counter that counts to 2 and make that toggel a pin?

mb2
Associate II
Posted on January 25, 2012 at 16:27

Thank for the input! We have deside to use a D-type flip-flop to do the trick.

Thanks

Mikkel