Help on SPI IO Expander MSP23S17

Status
Not open for further replies.

worksmart

Newbie level 5
Joined
Dec 13, 2004
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
78
aduc841.h

Hi all,

I stuck up with intrfacing SPI IO Expander MSP23S17 with ADUc841 microcontroller SPI port. IO expander is not responding. My K*e*i*l code I have gven below.
Can anybody help me.
Regards
Worksmart

//***************************************

#include<stdio.h>
#include <intrins.h>
#include <ADUC841.H>
sbit spi_cs = P3^4;
void write_spi(unsigned char c);
void delay(void);
void main(void)
{
unsigned int i=0;
unsigned char c=0;
SPICON=0x33;

spi_cs = 0;
delay();
write_spi(0x40);
write_spi(0x05);
write_spi(0xB0);
spi_cs = 1;
delay();
spi_cs = 0;
delay();
write_spi(0x40);
write_spi(0x0);
write_spi(0x0);
spi_cs = 1;
delay();
spi_cs = 0;
delay();
spi_cs = 0;
delay();
write_spi(0x40);
write_spi(0x09);
write_spi(0x0F);
spi_cs = 1;
delay();
while (1);
{
spi_cs = 0;
spi_cs = 1;
i=0;
while(--i);
}
}

void write_spi(unsigned char c)
{
//spi_cs = 0;
ISPI = 0;
SPIDAT = c; //write mode
while(!ISPI);
_nop_();
_nop_();
_nop_();
//spi_cs = 1;
}

void delay(void)
{
unsigned int i=100;
while(--i);
}

//*******************************
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…