How to Write and read data from MODEM registers using SPI

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to Write and read data from MODEM registers using SPI

1,252 Views
Paven
Contributor I
Hi..,

I am using MC13213 SRB board from freescale. I am programming that module using Codewarrior.

I am trying to access the MODEM Registers using SPI bus but i am unable to do that process.

Can anybody provide me a sample program for writing and reading data's from MODEM to MCU using SPI.

Thanks in advance. I am waiting for positive reply. Please be soon.
Labels (1)
0 Kudos
1 Reply

277 Views
Ware
Contributor III
 
 
 
 
Write 16bit "data" to 8bit "address":
Code:
   PTED &= ~0x04;     // SPI "chip enable" for modem/radio   SPID = address;    // Write address byte   while (!(SPIS & 0x20));  // wait for SPI ready   SPID =(unsigned char)(data>>8); // Write MSByte of data   while (!(SPIS & 0x20));  // wait for SPI ready   SPID = (unsigned char) data;    // Write LSByte of data   while (!(SPIS & 0x20));  // wait for SPI ready   for(i=0; i<8; i++) {    // small delay      __asm nop;   }   SPIS;  SPID; PTED |= 0x04;     // release SPI "chip enable" for modem/radio

 

Read 16bit "data" from 8bit "address" using 8bit "statusRegSave":
Code:
__asm TPA; __asm STA statusRegSave;__asm SEI;PTED &= ~0x04;     // SPI "chip enable" for modem/radioSPID=address;   for(i=0; i<8; i++) {    // small delay      __asm nop;   }SPIS;SPID;   for(i=0; i<8; i++) {    // small delay      __asm nop;   }SPIS;data=SPID;data = data<<8;   for(i=0; i<8; i++) {    // small delay      __asm nop;   }SPIS;data+=SPID;PTED |= 0x04;     // release SPI "chip enable" for modem/radio__asm LDA statusRegSave;__asm TAP;

 

Not sure about the Endianess on the read data.

Hope this helps,

 - Ware

 
0 Kudos