sudarshan mankad

SPI interfacing

Discussion created by sudarshan mankad on Dec 22, 2011
Latest reply on Jan 21, 2012 by bigmac

hey there. am working on SPI interface between two microcontrollers. mc9s12xdt512. help me out with the code.

#include /* common defines and macros */

 #include /* derivative information */

#pragma LINK_INFO DERIVATIVE "mc9s12xdt512"

 #include "main_asm.h" /* interface to the assembly module */

void main(void)

 {

 unsigned char x;

SPI0BR=0x20;

 SPI0CR1=0x54;

 SPI0CR2=0x0;
WOMS=0x0;

for(;:smileywink: {

 while(!(SPI0SR & SPI0SR_SPTEF_MASK));

 SPI0DR='B';

while(!(SPI0SR & SPI0SR_SPIF_MASK))

 x=SPI0DR;

}

 }

 thisis my code for transmitting a character. when i run it on a full chip simulation mode, i can see the character 'B' at SPI0DR. but when i run it on the controllers, i dannot see any thing at SPI0DR. on the recieveing side my code is

 void main(void)

 {

 unsigned char x;

 SPI0BR=0x20;

SPI0CR1=0x44;

 SPI0CR2=0x0;

WOMS=0x0;

for(;:smileywink: {

 while(!(SPI0SR & SPI0SR_SPTEF_MASK));

 SPI0DR=0;

 while(!(SPI0SR & SPI0SR_SPIF_MASK))

 x=SPI0DR;

} } my status register reads 20. and nothing at SPI0DR. help me out

Outcomes