Hello, I'm trying to use the SPI-interface on the MCB2100 board (with the LPC2129) but it just doesn't work. I can initialize the SPI0 and simulate the sending of data. But when I download it to the microcontroller the SPI-pins just don't work. I cannot see a clock or data on the pins. Below follows the code I use to set-up the SPI and the interrupt routine for SPI-interrupts:
void init_SPI0(void) { S0SPCCR = 30; //SCLK = 15Mhz/30 = 500kHz S0SPCR = 0xA8; //CPHA=1,CPOL=0,MSTR=1,LSBF=0,SPIE=1 VICVectCntl0 = 0x2A; //Enable vector for SPI0 interrupt VICVectAddr0 = (unsigned)SPI0_ISR; //Set ISR VICIntEnable = 0x0400; //Enable interrupt } void SPI0_ISR(void) __irq { switch(status) { case(0x01): //Busy with WREG S0SPINT = 0x01; //Clear interrupt flag S0SPDR = *SPI_buffer++; //Send next byte if(--SPI_bytecount) //Another byte??? { status = 0x01; //Yes } else { status = 0x02; //No } break; case(0x02): //Last byte sent S0SPINT = 0x01; //Clear interrupt flag IOSET0 = 0x01; //Pull chipselect high lock = 0; //Clear flag status = 0x00; //End of interface break; case(0x03): //Busy with RDATA S0SPINT = 0x01; //Clear interrupt flag *SPI_buffer = S0SPDR; //Read data SPI_buffer++; //Increment pointer if(--SPI_bytecount) //Another byte??? { status = 0x03; //Yes } else { status = 0x00; //No lock = 0; //Clear flag } break; default: //Default case break; } VICVectAddr = 0x00; //Reset interrupt hardware } void ADC_WREG(unsigned char *buffer, unsigned char bytecount) { lock = 1; //Set flag SPI_buffer = buffer; SPI_bytecount = bytecount; IOCLR0 = 0x02; //Pull Chipselect low S0SPDR = 0x50; //Send WREG, starting at adress 0 status = 0x01; //Set state } void ADC_RDATA(unsigned char *buffer) { lock = 1; //Set flag SPI_buffer = buffer; SPI_bytecount = 3; //3 bytes expected IOCLR0 = 0x02; //Pull chipselect low S0SPDR = RDATA; //Send RDATA status = 0x03; //Set state }