LPC2129 SPI communication problem

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC2129 SPI communication problem

1,280件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ravi7saini on Fri Jan 29 00:33:37 MST 2016
Hi all,

#Problem1:

I have designed a board using LPC2129 micro controller and Analog devices ADIS160006 accelerometer. I am trying to establish SPI communication using LPC2129 but somehow the SPI communication is not workinhg. I have tested the SCK pin with oscilloscope but there is no activity. LPC2129 is used as a master and ADIS16006 is used as a Slave. I am using Port 0.7 as GPIO for CS. There is activity on the chip select pin when monitored with the help of oscilloscope but not on other pins. Below is my code for establishing Communication. Please suggest some solution for the same.

#include "lpc21xx.h"
int main(void)
{
int temp= 0;
IODIR0 |= 0x00000080; // P0.7 defined as SS_ADIS16006
IOSET0 = 0x00000080; // SS_ADIS16006 = 1
PINSEL0 |= 0x00001500; // configure SPI0 pins (except SSEL0)
S0SPCCR = 12; // SCK = 1 MHz, counter > 8 and even
S0SPCR = 0xC8; // CPHA=1, CPOL=1, master mode, MSB first, interrupt disabled
while(1)
{
IOCLR0 = 0x00000080; // SS_ADIS16006 = 0
S0SPDR =0xaa;
     while(!(S0SPSR $ 0x80));
temp = S0SPDR;
IOSET0 = 0x00000080; // SS_ADIS16006 = 1
}
}

#Problem2:

In addition to the above problem my LPC2129 is not going in User flash mode (MEMMAP = 0x01) during power up. It stays in the bootloader mode (MEMMAP = 0x00).

If I power up the board after flashing the code nothing appears on the output. So I use ULINK-ME debugger and while debugging I have to manually change the memory mapping control setting and select the User flash mode. My question is after burning the code in the internal Flash memory and  why it is  not executing the code from the flash memory.
ラベル(1)
0 件の賞賛
返信
1 返信

1,125件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by eddiemallon on Tue Feb 02 13:53:43 MST 2016
Hi, I design some hardware with a 2129 interfaced to an AD7707. I did originally have problems trying to interface to the AD7707 due to lack of information. Eventually I did get it to work. Below are the sections of code to initiate the SPI, and transmit and receive from the AD7707. CS was connected to 0v to enable device permanently. Hope it helps.

void init_board (void)
{
PINSEL0 = 0x00005105;//En Pin 0.0,1 as UART TxD RxD; SPI_1 Pin 0.4,6,7
PINSEL1 = 0x000002A8;//En SPI_2 Pin 0.17,18,19,20
IODIR0  = 0x00400f00;//set P0.8,9,10,11, 22 to o/ps
}

void init_SPI (void)
{
S0SPCCR = 0x96;//Set SPI_1 clk to 98kHz
S0SPCR  = 0x20;//Set SPI_1 to master, MSB first, SCK active low.
IOSET0  = 0x00400A00;//set P0.11, 22 to 'Hi'; P0.8 to '0', P0.9 to '1' : 4-20mA
S1SPCCR = 0x96;//Set SPI_2 clk to 98kHz
S1SPCR  = 0x38;//Set SPI_2 to master, MSB first, SCK active high.
}

void AD7707_tx(void)
{
S1SPDR = AD7707_tx_data;//write data
while (S1SPSR != 0x80);//Wait for data sent; check SR bit7 is 'Hi'
}

void AD7707_rx(void)
{
AD7707_tx_data = 0x38;
AD7707_tx();
do
AD7707_drdy =IOPIN0;
while ((AD7707_drdy & 0x00200000) !=0);

AD7707_tx_data = 0x00;// data rqst
AD7707_tx();
rxdata_H  = S1SPDR;

AD7707_tx_data = 0x00; // data rqst
AD7707_tx();
rxdata_L = S1SPDR;

AD7707_rx_data  = ((rxdata_H <<8) | rxdata_L);
}

void init_AD7707(void)
{
IOCLR0 = 0x00400000;// reset AD7707 po.22
delay2();
IOSET0 = 0x00400000;
AD7707_tx_data = 0x20;//write data to Comm Reg: An1_Locom selected. 
AD7707_tx();
AD7707_tx_data = 0x1c;//write data to Clk Reg: 
AD7707_tx();
AD7707_tx_data = 0x10;//write data to Comm Reg: An1_Locom selected.  
AD7707_tx();
AD7707_tx_data = 0x44;//write data to SetUp Reg: An1_Locom selected, unipolar.  
AD7707_tx(); 
}
0 件の賞賛
返信