SPI problem (LPC2368, IAR)

Status
Not open for further replies.

kender

Advanced Member level 4
Joined
Jun 19, 2005
Messages
1,425
Helped
138
Reputation
276
Reaction score
39
Trophy points
1,328
Location
Stanford, SF Bay Peninsula, California, Earth, Sol
Activity points
10,035
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: **broken link removed**. 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

Cookies are required to use this site. You must accept them to continue using the site. Learn more…