I got a very magical problem that I can slove by myself.
I need your help...Thank you!
Device: 9S12XS128 80pin
IDE: Codewarrior 5.0
Problem:
When I use SPI Master mode,my initial code as below doesn't work:
MODRR = 0x10; //spi use m4 m5 port
(void)SPI0SR; /* Read the status register */
(void)SPI0DRL; /* Read the device register */
SPI0CR1 = 0x50;
SPI0CR2 = 0x08;
SPI0BR = 0x01;
But when I set the Port P to output mode,just like this:
DDRP=0XFF; //Set Port P to output mode
MODRR = 0x10; //spi use m4 m5 port
(void)SPI0SR; /* Read the status register */
(void)SPI0DRL; /* Read the device register */
SPI0CR1 = 0x50;
SPI0CR2 = 0x08;
SPI0BR = 0x01;
It can work very perfectly now.
What happen?Why I must set the Port P to output mode when I want use the SPI module?