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.
Hello everyone i am new to microcontroller programming. I am doing a project using LPC1768. To learn about spi i used a debug feature of debugger. I wrote the follwing program for spi simulation.
#include <LPC17xx.H> int main(void) { SystemInit(); LPC_SC->PCONP |= 0x00000100; //LPC_SC->PCLKSEL0 |= 0x00200000; LPC_GPIO0->FIODIR |= 0x00010000; LPC_GPIO0->FIOSET |= 0x00010000; LPC_PINCON->PINSEL0 &= 0xC0000000; LPC_PINCON->PINSEL1 &= 0xC000003F; LPC_SPI->SPCR = 0x38; LPC_SPI->SPCCR = 0x08; while(1) { LPC_SPI->SPDR = 0x01; while(!(LPC_SPI->SPSR & 0x80)); } }
in simulation after LPC_SPI->SPDR = 0x01; i am expecting content of SPDR register to be 01.But in simulation SPI dialog box it is showing 00. SPIF bit set to be 1. In the logic analyzer SPI_OUT is always 0.
Thanks in advance.
Regards
Thanks for your reply. i found the problem. As u rightly pointed out the problem was with the settings. i have some questions first is that SPDR register value never changes why is that? second what is spi_out? is this signal same as MOSI? thanks again for ur reply
regards