Interfacing Sharp LCD with K60

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Interfacing Sharp LCD with K60

Jump to solution
635 Views
nithinnagaraj
Contributor I

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.

0 Kudos
1 Solution
480 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Nithin:

Since I don't see your whole source, especially where you open this spi device , It is hard to locate the root cause. I would suggest you check the the chip select.

For more details, please see chapter 9.6,  Using the SPI driver

Freescale_MQX_4_2\doc\mqx\MQX_IO_User_Guide.pdf

For details how to implement SPI, please look at SPI example codel

Freescale_MQX_4_2\mqx\examples\spi

Regards

Daniel

View solution in original post

0 Kudos
2 Replies
481 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Nithin:

Since I don't see your whole source, especially where you open this spi device , It is hard to locate the root cause. I would suggest you check the the chip select.

For more details, please see chapter 9.6,  Using the SPI driver

Freescale_MQX_4_2\doc\mqx\MQX_IO_User_Guide.pdf

For details how to implement SPI, please look at SPI example codel

Freescale_MQX_4_2\mqx\examples\spi

Regards

Daniel

0 Kudos
480 Views
nithinnagaraj
Contributor I

Thank you for the reply Daniel. 

0 Kudos