C47D / Nokia5110_PSoC_SCB_Based

Custom Component for PSoC 4, driven by SPI (SCB Based) for Nokia 5110 displays.
1 stars 2 forks source link

Issue with SPI SCB #1

Closed mirapira closed 5 years ago

mirapira commented 5 years ago

Hi, I had an issue using your code in a Psoc4 (4245LQI). It seems that the commands and data were getting mixed up on the SCB buffer. I had this issue before with a NRF24. Forcing the CE to drop from byte to byte is not enough, and by the time the command pin is asserted, the SCB was still sending data from previous commads.

The fix is very simple: Check for the idle state before sending data to SCB(or SCB buffer). Check the bold code. Thanks, Marco

/-------------------------------------------------------------------------------------------------- // Name : $INSTANCE_NAME_SendData // Description : Sends data to display controller. // Argument(s) : data -> Data to be sent // Return value : None. //--------------------------------------------------------------------------------------------------/ void $INSTANCE_NAME_SendData(uint8_t data){ while($INSTANCE_NAME_SPI_SpiIsBusBusy()); // Wait until SPI cycle complete. $INSTANCE_NAME_Control_Write(SET_RST_SET_DC); $INSTANCE_NAME_SPI_SpiUartWriteTxData(data); // Send data to display controller. while($INSTANCE_NAME_SPI_SpiIsBusBusy()); // Wait until SPI cycle complete. }

/-------------------------------------------------------------------------------------------------- // Name : $INSTANCE_NAME_SendCommand // Description : Sends command to display controller. // Argument(s) : command -> Command to be sent // Return value : None. //--------------------------------------------------------------------------------------------------/ void $INSTANCE_NAME_SendCommand(uint8_t command){ while($INSTANCE_NAME_SPI_SpiIsBusBusy()); // Wait until SPI cycle complete. $INSTANCE_NAME_Control_Write(SET_RST_CLEAR_DC); $INSTANCE_NAME_SPI_SpiUartWriteTxData(command); // Send command to display controller. while($INSTANCE_NAME_SPI_SpiIsBusBusy()); // Wait until SPI cycle complete. }

C47D commented 5 years ago

Hi,

Thanks for the report, I haven't touch this component for a while but I will add your patch.

C47D commented 5 years ago

@mirapira Fixed with your suggestion.

As you have noticed this component works only with the SCB based SPI component. I had gained some knowledge with the (nRF24 Component) about doing components that works with both SCB and UDB based SPI.

I will start working on a new Nokia 5110 component with such behavior, if you are interested see Nokia5110 Component, i will work on it this week.