Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: SPI error µc as master

2004-12-07 by domingos_bento

Hello,

try it for you read:

SPI0_SPDR = 0x00;
		while(!(SPI0_SPSR & SPIF)){
  }
			read = SPI0_SPDR;


Good work!!!
           Domingos







--- In lpc2000@yahoogroups.com, Sridhar gadda <sridhargadda@y...> wrote:
> Hello, 
>  
>           I have configured lpc2129 as master and ADC as slave, but
when I compiled, no errors comes but my µc doesn't work to my
application. I have doubt that my SPI interface  is not correct ? 
> my code is 
>  
> #include <LPC21xx.H>
> #define data 0x00
> int main (void)
> {
>     PINSEL0 = 0x00001500;      /* SCK0, MISO, MOSI for SPI0 enabled*/
>   init_spi();
>   init_spi_write(); 
>   init_spi_read(); 
> }
>  
> void init_spi (void)
> { 
>    VPBDIV = 0x00;
>    S0SPCR = 0x68;    /*master as SPI, LSB first*/
>    S0SPCCR = 0x08;
> }
>  
> int init_spi_write (void)
> {
>   S0SPDR = data;    /*write data to data register*/
>   return (S0SPSR);   /* read status register so SPIE bit clears*/
> }
>  
> int init_spi_read (void)
> {
>   char read;
>   read = S0SPDR;     /*read data from slave*/
>   return (S0SPSR);  /* read status register so SPIE bit clears*/
> }   
>  
> could anyone indentify my SPI Interface is right ? configrution as
master and only one slave.
>  
> I am looking forward to your replying.
>  
> with regards, 
>  
> sridhar
>  
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> [Non-text portions of this message have been removed]

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.