PV198 - SPI II One-chip Controllers Daniel Dlhopolček, Marek Vrbka, Jan Koniarik, Oldřich Pecák, Tomáš Rohlínek, Ján Labuda, Jan Horáček, Matúš Škvarla Faculty of Informatics, Masaryk University 9/2023 Introduction Intro Switch the branch to Week_09! Discussion of HW8 ·PV198 - SPI II ·9/2023 2 / 11 Task Context In some cases it is necessary to serve not to rule. Goal is to implement SPI slave functionality: Instead of driving SPI bus, react to master device. Data should be prepared in advance, goal is to react to requests: You will be provided an interface with 3 features in blocking mode and you will implement these features non-blocking mode. ·PV198 - SPI II ·9/2023 3 / 11 Task Goal SPI slave will be able to react to two types of messages, type of message is deduced from first byte: 1. WRITE: print all subsequent bytes to UART. 2. READ: report latest measured ADC value. First byte in slave’s reply is a counter - number of correct communications completed. ·PV198 - SPI II ·9/2023 4 / 11 Task Template Template uses a non-blocking polling method: 1. DSPI_SlaveUserCallback This function is called after a transfer is finished (similar to interrupt). 2. while (!isTransferCompleted) This while loop keeps you blocked, remove it with caution. 3. The rest of implementation is up to you. ·PV198 - SPI II ·9/2023 5 / 11 Task Wiring Rpi pico FRDM-K66P GND GND GP2 PTD1 GP3 PTD3 GP4 PTD2 GP5 PTD0 ·PV198 - SPI II ·9/2023 6 / 11 Task Counter Counter header: 1. Every time you finish either WRITE or READ operation, count increases. 2. Count is represented by 8bit unsigned number. It can overflow. 3. Repeated comunication with neither READ nor WRITE does not affect the counter. ·PV198 - SPI II ·9/2023 7 / 11 Task READ Read ADC value: 1. Read values from ADC1 SE_13. 2. Read command is identified by value 0x55. 3. Expected ADC value is Big Endian, 12bit long. 4. Prepare ADC value in advance. ·PV198 - SPI II ·9/2023 8 / 11 Task WRITE Transmit 16 recieved bytes recived by SPI to UART: 1. Configure PTB11 as UART3_TX. 2. Write command is identified by value 0xCC. 3. You will recieve a chunk of 16 bytes. After you get them all, print your data to UART. 4. Beware: blocking transmit on UART might give you problems in callback. ·PV198 - SPI II ·9/2023 9 / 11 Task Homework Finish assignment for the lesson. Scope of lesson is deliberately larger. ·PV198 - SPI II ·9/2023 10 / 11 Task Bonus Recieve chunks of 3 bytes. 1. Configure PTB10 as UART3_RX. 2. Write command is initialized by value 0x37. 3. You will be asked to return 3 bytes stored, that you recieved by UART3_RX. 4. If there were no data stored, return random data but do not increment counter. 5. Make internal memory 64messages long. If more massages recieved, overwrite the oldest one. ·PV198 - SPI II ·9/2023 11 / 11