Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

SPI problem (LPC2368, IAR)

Status
Not open for further replies.

kender

Advanced Member level 4
Joined
Jun 19, 2005
Messages
1,422
Helped
138
Reputation
276
Reaction score
39
Trophy points
1,328
Location
Stanford, SF Bay Peninsula, California, Earth, Sol
Activity points
9,968
Colleagues,

Wrote a small program in IAR EWARM to test SPI. It runs, but SCLK and MOSI do not show up on the oscilloscope. Here’s the code, which actually makes SPI transactions:
Code:
while(1)
{
      S0SPCCR = 32;   // SCLK rate
      S0SPCR = 
        0x00000000 |  // MOSI valid on raising edge of SCLK (CPOL=CPHA=0)
        0x00000020 |  // master (AD7390 DAC is the slave)
        0x00000000 |  // MSbit first
        0x00000000 |  // SPI interrupt inhibited
        0x000C0004;   // transmit 12 bits (BitEnable, BITS)
      DAC_xLD_FSET = DAC_xLD_MASK;   // drive LD# high
      S0SPDR = 0x7FF; // write to the data register (this will start the transmission and clear the SPIF bit)
      while ( !(S0SPSR & 0x80) ); // poll SPIF bit for the end of transaction
      DAC_xLD_FCLR = DAC_xLD_MASK;   // drive LD# low (data gets written from serial shift register to DAC register)
}
With a scope, I can see the LD# line toggle up and down, so this program doesn’t hang while polling for SPIF. Rang-out the wiring - it seems to be correct. Nothing is shorted to Vcc or GND. Added a pullup and enabled SSEL in PINSEL3, following this advice: https://tech.groups.yahoo.com/group/lpc2000/message/4363. Checked that PINSEL doesn’t get overwritten. But still no clock.

Here’s the initialization of my SPI peripheral:
Code:
void SPI_Init()
{
  PCONP_bit.PCSPI = 1;
  PINSEL3 = 0x0003CF00;
}
Can you spot any errors? What else can I check?

Thanks,
- Nick
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top