PDA

View Full Version : Emulating SPI rom with PICbasic pro?



CuriousOne
- 17th July 2015, 12:33
Hello.

I want to emulate SPI rom with PIC, to test various things. The original device works as follows - on power up, it is queried and 32 bytes read. I know that we can work with SHIFTOUT do represent PIC as SPI slave, but how to start sequence? i.e. if I just put corresponding SHIFTOUT statement into loop, it will transmit automatically when CS pin will be active and clock signal applied to clock pin?

HenrikOlsson
- 17th July 2015, 18:38
Hi,
As you say SHIFTIN/SHIFTOUT are for when the PIC is the master, it's always the PIC that supplies the clock - it can't shift data out in sync with an external clock - which is what you need. So shiftin/shiftout won't work for doing SPI slave.

A PIC with a MSSP module can act as either a master or a slave. I believe there are some basic example programs, both for master and for slave (you obviously want slave) supplied with PBP.

What's the clock frequency of the SPI bus you're want to put this emulated memory on?

/Henrik.