We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I have a LPC2294 board. When I try to init SPI program crashes. OS is RL-ARM and spi_init function executes "SSPCR0 = 0x00C7;" instruction in simulator then it gives the folloving error: "Data Abort: Thumb Instruction at 00000C7EH, Memory Access at E005C000H"
void spi_init (void) { /* Initialize and enable the SSP Interface module. */ U32 i; /* SSEL is GPIO, output set to high. */ IODIR0 |= 1<<20; // OK IOSET0 = 1<<20; // OK /* SCK1, MISO1, MOSI1 are SSP pins. */ PINSEL1 = (PINSEL1 & ~0x000003FC) | 0x000000A8; /* Enable SPI in Master Mode, CPOL=1, CPHA=1 (Clock low-active). */ SSPCR0 = 0x00C7; //!!!!!CRASHES HERE SSPCR1 = 0x0002; SSPCPSR = 0xFE; /* Send SPI Command with card not selected at 400 KBit. */ for (i = 0; i < 16; i++) { spi_send (0xFF); } /* Enable SSP auto select. */ PINSEL1 |= 0x00000200; }
Have you checked that the header file has the correct address for the SSPCR0 register?
Have you turned on power to the device?
Have you verified that SSPCR1 doesn't already have the device enabled?
Thanks for fast response,
I saw that register addresses are not the same in datasheet and header file. I thought that header should be ok. Thanks for reminding that.. I will try. bye
"I saw that register addresses are not the same in datasheet and header file. I thought that header should be ok."
No: the Datasheet is the source document - it is written by the chip manufacturer.
Header files are written by 3rd parties (eg, Keil) - they should be based upon the Datasheet, but mistakes happen...