Go Down

Topic: Could an AVR SPI slave bit-bang its own clock with another pin? (Read 606 times) previous topic - next topic

bill2009

I want to use an attiny2313 as a communications subsystem for another microprocessor.  it is hooked up as an SPI slave and just echoes the spi comm on the uart.  The clock is currently being generated by another circuit (another attiny as it happens) but, If I have a spare pin, could the attiny2313 do it itself?

CrossRoads

Slave does not generate the SPI clock, the master does. Were it to become an SPI master, it would have to generate a clock.
Can you buffer the clock from the master and pass it along externally to the other device?
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

bill2009


Slave does not generate the SPI clock, the master does. Were it to become an SPI master, it would have to generate a clock.
Can you buffer the clock from the master and pass it along externally to the other device?

Thanks, I know that the master generates the clock, but in this case the "master" is a couple of shift registers and a clock generator.  If I can get the AVR slave to replace the clock generator I can save a chip.  I may just have to try it once everything else is working.

CrossRoads

So you want it to generate the burst of 8 clocks once it sees it's chip select line go low?
I suppose you could turn on a PWM output and then back off again with some assembly level code to do it quick; if your SPI is at 4MHz tho you may not have time.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

bill2009


So you want it to generate the burst of 8 clocks once it sees it's chip select line go low?
I suppose you could turn on a PWM output and then back off again with some assembly level code to do it quick; if your SPI is at 4MHz tho you may not have time.

Yes, it wouldn't be checking its chip select line, it would be a different pin because it might not be the active slave in the conversation but that is the idea.  In my current implementation another attiny is watching the trigger pin and generating the 8 clocks.

As I think about it though, I have to turn interrupts off in the clock-generator attiny not to miss trigger events  and that would make it tough to use the uart and spi hardware.

so... overall dumb idea.  Thanks though.

Go Up