Lpc1769 SPI function from lpx17xx.c

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Lpc1769 SPI function from lpx17xx.c

3,352 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Carsten on Sun Jun 23 07:37:12 MST 2013
Hello,

hopefully someone of you can help me to identify my faikure using the SPI_ReadWrite() function from the code read lib lpc17xx.c.

The controller shall run together with a the display MI0283QT-2 from Watterott.
With some help from the forum I was able to get the display running by using the SPI_SendData() with a added wait/check function.
Now I would like to use the SPI_ReadWrite() because of the touch function of the display.

void lcd_draw(unsigned int color)
{
    unsigned int temp;

//    SPI_SendData(LPC_SPI, color>>8);
//    SPI_SendData(LPC_SPI, color);

    temp = color>>8;
    xSPI_Data.tx_data = &temp;
    xSPI_Data.rx_data = spireadbuf;
    xSPI_Data.length = sizeof(color>>8);
    SPI_ReadWrite(LPC_SPI, &xSPI_Data, SPI_TRANSFER_POLLING);

    temp = color;
    xSPI_Data.tx_data = &temp;;
    xSPI_Data.rx_data = spireadbuf;
    xSPI_Data.length = sizeof(color);
    SPI_ReadWrite(LPC_SPI, &xSPI_Data, SPI_TRANSFER_POLLING);

  return;
}
Is someone able to explane me what is wrong with my code?
0 项奖励
回复
8 回复数

3,244 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Carsten on Mon Jul 08 10:48:20 MST 2013
So,

it took me some time but i was able to identify my problem and understand the lpc17xx_spi.c lib from code red.

My problem was that I never used memset() to fill the struct with "0", so the read-function tried to recieve data ended in a endless loop and case problems with the display communication.:rolleyes:

char txBuffer[2];

    SPI_DATA_SETUP_Type spiDataCfg;
    memset(&spiDataCfg, 0, sizeof(SPI_DATA_SETUP_Type));

    txBuffer[0] = color >> 8;
    txBuffer[1] = color;

    spiDataCfg.tx_data = txBuffer;
    spiDataCfg.length = sizeof(txBuffer);

    SPI_ReadWrite(LPC_SPI, &spiDataCfg, SPI_TRANSFER_POLLING);
Now it works as expected and the next step will be to get the touch panel running together with the display.
0 项奖励
回复

3,244 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Sun Jun 23 12:57:24 MST 2013
I'm sorry to say that, but your project is throwing out a lot of warnings, your signal timing is ridiculous and you are using a complicated NXP library which you don't understand?

That's brave.

Are you sure you don't want to use the new V2 Version with included LPC1114? Released last week: http://www.watterott.com/de/MI0283QT-Adapter-v2

It has an UART an SPI interface and no ADS7846.

Anyway, you should scope the signals to control if your code is working. This combined read/write functions can be tricky.
0 项奖励
回复

3,244 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Carsten on Sun Jun 23 12:19:32 MST 2013
It seems there little missunderstanding.:eek:

The aim is to communicate with the ADS7846 but at the moment it's [U]not[/U] connected.

I have used the function SPI_SendDate() to get the display running but I want to use the SPI_WriteRead() function. And it's not clear for me how to fill the struct SPI_DATA_SETUP_Type to get the display running.

To answer the rest of you question:

1. The display power is connected to J6-1 (GND) and J6-28 (3.3V)
2. Yes, I'm using a lpc1769
3. Standard CMIS is used
4. No, only a short delay is expcted :D


Sure my second part will be to communicate with the ADS7846 and based on my rudimental C language knowledge is could be also an question to the forum and maybe you ;)
0 项奖励
回复

3,244 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Sun Jun 23 11:47:08 MST 2013
I'm a little bit confused. You are trying to run the ADS7846 without connecting it? Is it a new unknown wireless version?

Are you running your Display with any voltage or is it wireless, too.

Is the project you have posted running with an LPC1769?
Is it a standard CMSIS setup with 100MHz?
Is your funny delay function generating ms with that setup?
void delay_ms(int n)
{
    volatile int d;
    for (d=0; d<n*3000; d++){}
}
0 项奖励
回复

3,244 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Carsten on Sun Jun 23 11:36:38 MST 2013
jups, sorry :D
0 项奖励
回复

3,244 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Sun Jun 23 11:22:48 MST 2013
Sorry, can't read this 198px × 280px JPG :)
0 项奖励
回复

3,244 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Carsten on Sun Jun 23 11:16:29 MST 2013
It's the old Rev 1.0 together with the shield http://www.watterott.com/de/MI0283QT-2.
The wiring can be found in the attachted pic.
0 项奖励
回复

3,244 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Sun Jun 23 10:29:08 MST 2013
Could you please post a schematic how you've connected CON1 and which display you are using (V1.0 ) ?
0 项奖励
回复