AnsweredAssumed Answered

Interfacing Sharp LCD with K60

Question asked by Nithin Nagaraj on May 18, 2017
Latest reply on Jul 11, 2017 by Nithin Nagaraj

Hello, 

I am trying to interface LS013B7DH06 Sharp-memory LCD with K60 via SPI interface. I have written my spi_write function as follows,

{SPI2_PUSHR = ((SPI_PUSHR_CTAS(0x00)) | (SPI_PUSHR_PCS(63)) | (SPI_PUSHR_CONT_MASK) | SPI_PUSHR_TXDATA(0x20));
while(((SPI2_SR & SPI_SR_TCF_MASK) == 0));
SPI2_SR |= SPI_SR_TCF_MASK;
SPI2_SR |= SPI_SR_TFFF_MASK;
// end of queue
SPI2_PUSHR = ((SPI_PUSHR_CTAS(0x00)) | (SPI_PUSHR_PCS(63))| (SPI_PUSHR_EOQ_MASK) | (SPI_PUSHR_CONT_MASK & 0x00) | SPI_PUSHR_TXDATA(0x00));
while(((SPI2_SR & SPI_SR_TCF_MASK) == 0));
SPI2_SR |= SPI_SR_TCF_MASK;
SPI2_SR |= SPI_SR_TFFF_MASK;}

 

Lcd write is happening fine and i am able to write all my graphics api. Now when i try to write the SPI_Write Function using the following code, 

void bspSpiWrite ( uint8_t addr)
{
uint8_t buffer[1];
uint32_t data;
_mqx_int result;
buffer[0]= addr;  // (0x20) 0r (0x80)
result = fwrite( buffer, 1, sizeof(buffer), spifd);
if (result != 1)
printf("ERROR");
else
printf("OK");
fflush(spifd);
}

Now since its a complete MQX api (fwrite) and this is what i need to implement, my code is not working if i use the above function. May i request anyone to please explain me why it is working with 1st case and why not with 2nd? What is wrong with the 2nd function??

It would be a great if someone helps me out on this. 

 

Thanks in advance.

Outcomes