![]() The SENDREC function is written in a way that multiple bytes can be chained by calling it in sequence as often as needed. CS has to stay active during such a transfer over all bytes to be written (and read), acting as transaction marker. This is the base for multi-byte transfer, important for the RFM95, as each of it's transfers always starts with an address followed by one or more data bytes. Note that the routine does not perform step 7, it leaves chip select active. Repeat step 2 thru 5 for all bits/bytes to be transferred.The important part is, as mentioned, to stay with the sequence: MOV A,C Restore Data with clock cleared (*7) ![]() while RECeiving the peripherals response at the same time Starts or continues an SPI transaction by SENDing a byte Since sending and receiving is interleaved a single routine can be used: SPI_CLK EQU 4 LD A,000001111b Set CS high to deselectīy calling SPI_INIT the interface will be put into operating condition. LD A,000000111b Interrupt control, no interrupt (see p.191) (All references relate to the Z80 Family CPU Peripherals User Manual UM008101-0601) For other modes this may need to be adapted.Ī subroutine to initialize this setup may look like this: We also assume the device to be operated in Mode 0 (CPOL=0, CPHA=0) as the RFM95 does. Let's say we have a Z80-PIO connected to a Z80-CPU at I/O address 20h (*4) and use port A with its first 4 lines assigned as (*4): Any interface able to provide three output lines and one input line can be used. It can be handled as slow as a bit per day. The great advantage is that SPI does not require any specific timing (*3) as long as the basic sequence is followed. SS/CS - Out - Slave Select, also called Chip Select, selecting the external interface.SCLK - Out - Serial Clock, a signal to be toggled once per bit.MISO - In - Master In Slave Out, the data returned by external hardware.MOSI - Out - Master Out Slave In, the data the CPU sends out.Unless one intends to use some dedicated hardware, like a shift register (useful if speed is of concern), all it needs are 3 port bits for the data interface, plus one port bit per device connected (*2) for it's basic signals: I tend to use SPI for all my micro controller designs (*1). It was designed especially to work with low end processors. SPI is eventually the most simple interface to implement.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |