Pages: [1]   Go Down
Author Topic: Could an AVR SPI slave bit-bang its own clock with another pin?  (Read 453 times)
0 Members and 1 Guest are viewing this topic.
ottawa, canada
Offline Offline
God Member
*****
Karma: 6
Posts: 990
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 515
Posts: 26261
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

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.

ottawa, canada
Offline Offline
God Member
*****
Karma: 6
Posts: 990
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 515
Posts: 26261
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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.

ottawa, canada
Offline Offline
God Member
*****
Karma: 6
Posts: 990
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: