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.
In addition to studying the chip documentation, don't the comments in the code give you some clues...?
Thank you.. very much
Which microcontroller model are you referring to ?
bebin shaad jan mitoni behem begi che jori ba lib haye RL-ARM kar mikoni? man not allowed has tam
LPC2148
The you can use ARM wizard to make the SPI settings http://alexan.edaboard.eu/
You have to set the core clock (CCLK) and PCLK divider manually to the settings you use in your mcu (for example 60MHz and 1/4 which means that the SPI peripheral clock is 15MHz), then you can set the SPI/SSP frequency by using up/down arrow on the divider value edits or by right clicking and selecting the target frequency.
In either case it would be a good idea to check the manual so that you know of the calculations involved, then use the application to do it automatically.
Alex