Hallo zusammen, ich versuche gerade mein SPI zum Bildschirm effizienter zu gestalten und blicke einige Register nicht ganz (trotz Datenblatt). vielleicht kann mich jemand aufklären :) unten stehen einige Datenblatt auszüge. Ich möchte gerne kontinuierlich Daten senden, sprich immer daten im FIFO haben die gesendet werden. Der FIFO ist anscheinend 2 byte groß. Frage 1 stehen mir insgesamt 3 byte zur verfügung? 2 im FIFO + TXB? Frage 2 was ist gemeint mit " 1 = TxFIFO data is required for a transfer 0 = TxFIFO data is not required for a transfer " verstehe ich nicht ganz. Frage 3 BUSY bezieht sich ja auf das senden, verstehe ich es also richtig das mein Fifo leer sein kann und Busy high? Frage 4 Wie wäre eine mögliche und sinnvolle Routine? Ich würde immer Byteweise schreiben sobald TXWE 0 ist, jedoch wird der FIFO ja bitweise geleert oder? was bedeutet das ich bei 15 von 16 bits bereits 0 hätte? auf das enden des Busy Bit wollte ich nicht warten. wenn ich warte bis der Fifo leer ist (TXBE = 1) bis ich neue daten sende, habe ich dann einen aussetzer oder ist der Fifo leer wärend das letzte byte noch in sendung steht? irritierend ist das im mcc Code keinerlei abfragen stattfinden. vielleicht könnt ihr mich ein wenig aufklären das verwirrt mich in summe etwas :) LG uint8_t SPI1_ExchangeByte(uint8_t data) { SPI1TCNTL = 1; SPI1TXB = data; while(!PIR2bits.SPI1RXIF); return SPI1RXB; } void SPI1_WriteBlock(void *block, size_t blockSize) { uint8_t *data = block; while(blockSize--) { SPI1_ExchangeByte(*data++); } } TXWE: Transmit Buffer Write Error bit 1 = SPIxTxB was written while TxFIFO was full 0 = No error has occurred TXBE: Transmit Buffer Empty bit (read-only) 1 = Transmit buffer TxFIFO is empty 0 = Transmit buffer is not empty TXB[7:0]: Transmit Buffer bits (write only) If TXFIFO is not full: Writing to this register adds the data to the top of the TXFIFO and increases the occupancy of the TXFIFO write pointer If TXFIFO is full: Writing to this register does not affect the data in the TXFIFO or the write pointer, and the TXWE bit of SPIxSTATUS will be set TXR: Transmit Data-Required Control bit(2) 1 = TxFIFO data is required for a transfer 0 = TxFIFO data is not required for a transfer RXR: Receive FIFO Space-Required Control bit(2) 1 = Data transfers are suspended if the RxFIFO is full 0 = Received data is not stored in the FIFO BUSY: SPI Module Busy Status bit(1) 1 = Data exchange is busy 0 = Data exchange is not taking place 32.5.2 TRANSMIT-ONLY MODE When TXR is set and RXR is clear, the SPI host is in Transmit-Only mode. In this mode, data transfer triggering is affected by the BMODE bit of SPIxCON0. When BMODE = 1, data transfers will occur whenever TXFIFO is not empty. Data will be transmitted as soon as the TXFIFO register is written to, matching functionality of SPI (MSSP) modules on previous 8-bit Microchip devices. The SPIxTCNT will decrement with each transfer. However, when SPIxTCNT is zero the next transfer is not inhibited and the corresponding SPIxTCNT decrement will cause the count to roll over to the maximum value. Any data received in this mode is not stored in RXFIFO. Figure 32-4 shows an example of sending a command and then sending a byte of data, using this mode. When BMODE = 0, the transfer counter (SPIxTCNTH/ L) must also be written to before transfers will occur, and transfers will cease when the transfer counter reaches ‘0’. For example, if SPIxTXB is written twice and then SPIxTCNTL is written with ‘3’, the transfer will start with the SPIxTCNTL write. The two bytes in the TXFIFO will be sent after which the transfer will suspend until the third and last byte is written to SPIxTXB.
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.