In following function of initializing of SPI, I am not getting two things Please help me.
1. How to choose the value of SPCCR=0x8. ? 2. As well as why put 0x1 in to the VPBDIV. ?
void Initialize() {
PINSEL0=0x5500;
/* Set pclk to same as cclk */ VPBDIV=0x1;
/* Set to highest speed for SPI at 10 MHz- > 1.25 MHz */ SPCCR=0x8;
SPCR=0x20; }
Same answer to both:
1) Open datasheet / user manual for your chip 2) locate register by name 3) read entire section its description appears in 4) read enough of the rest of the documents to understand all the terms and concepts mentioned in the section your just read. Yes, the first few times around that may very well mean you have to read the entire thing. 5) apply knowledge.