Forums

F149 SPI issue with Serial EEPROM

Started by europus October 30, 2007
Hi all ,

I have F149 on SPI bus with AT25160A SPI EEPROM....My
problem is, inspite of all signals good in timing etc...I am not able to
receive a character in RXBUF0......I can see everything good on
oscilloscope and see that 0X41...i.e 'A' is output from EEPROM but
RXBUF0 receives 0....Does anyone have any clue to this issue?? Thanks in
advance....Driver that i am using is attached....

unsigned short e2prom_read(unsigned int read_addr)
{
int delay;
short read_data;
short read_high_addr;
short read_low_addr;
read_addr=0X0010;
P3OUT ^= 0X10; //EEPROM CS3 low//
P2OUT |= 0X80; //0-20mV DAC unselect//
P3OUT |= 0X01; //P3.0 Main DAC deselect//
read_high_addr = (read_addr & 0XFF00)/0X100;//Separate High Byte //
read_low_addr = (read_addr & 0X00FF);//Separate Low Byte//
while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
{
TXBUF0=0X03; //Instruction for Reading EEPROM//
}
while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
{
TXBUF0=read_high_addr; //Write high byte of address for EEPROM//
}
while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
{
TXBUF0=read_low_addr; //Write high byte of address for EEPROM//
}
while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
{
TXBUF0=0X00; //Dummy Write for receive clock//
}
while (!(IFG1 & URXIFG0));
{
read_data=RXBUF0; //Assign data to variable//
}
for(delay=0;delay<240;delay++);
P3OUT |= 0X10; //EEPROM CS3 high (deselect)//
while (!(IFG2 & UTXIFG1)); //Transmit digit1 to serial port if UTXBUF0
empty//
{
TXBUF1=read_data;
}
return read_data;
}

Beginning Microcontrollers with the MSP430

Thanks a lot kris.....I tried what you suggested .....But it didn;t work.....RXBUF still reads 0X00.....and moreover there was a massive tremors of earthquake here in Bay area....so talk to you tomorrow....thanks again....

Microbit wrote: Hi,

I think your problem is that you're not waiting till the dummy write byte for RX is flushed
through properly, before reading RXBUF0.
Don't wait for RXIFG0 to set, wait for TXIFG0 to set - indicating that the RXd byte (if any)
has been clocked in to the F149 - and then read RXBUF0.
(RXIFG0 will still be set from the previous transaction, hence you're not waiting for the SPI RX
transaction to complete)
Because SPI always _exchanges_ 2 bytes in a bus transaction, you must assume data has been
received, whether the slave actually provided one or not.

PS : be careful with your commenting style. IMO it's better to use C++ style solely or else use
/* .... */ style.

Best Regards,
Kris

-----Original Message-----
From: m... [mailto:m...] On Behalf Of europus
Sent: Wednesday, 31 October 2007 10:25 AM
To: m...
Subject: [msp430] F149 SPI issue with Serial EEPROM

Hi all ,

I have F149 on SPI bus with AT25160A SPI EEPROM....My
problem is, inspite of all signals good in timing etc...I am not able to
receive a character in RXBUF0......I can see everything good on
oscilloscope and see that 0X41...i.e 'A' is output from EEPROM but
RXBUF0 receives 0....Does anyone have any clue to this issue?? Thanks in
advance....Driver that i am using is attached....

unsigned short e2prom_read(unsigned int read_addr)
{
int delay;
short read_data;
short read_high_addr;
short read_low_addr;
read_addr=0X0010;
P3OUT ^= 0X10; //EEPROM CS3 low//
P2OUT |= 0X80; //0-20mV DAC unselect//
P3OUT |= 0X01; //P3.0 Main DAC deselect//
read_high_addr = (read_addr & 0XFF00)/0X100;//Separate High Byte //
read_low_addr = (read_addr & 0X00FF);//Separate Low Byte//
while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
{
TXBUF0=0X03; //Instruction for Reading EEPROM//
}
while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
{
TXBUF0=read_high_addr; //Write high byte of address for EEPROM//
}
while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
{
TXBUF0=read_low_addr; //Write high byte of address for EEPROM//
}
while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
{
TXBUF0=0X00; //Dummy Write for receive clock//
}
while (!(IFG1 & URXIFG0));
{
read_data=RXBUF0; //Assign data to variable//
}
for(delay=0;delay<240;delay++);
P3OUT |= 0X10; //EEPROM CS3 high (deselect)//
while (!(IFG2 & UTXIFG1)); //Transmit digit1 to serial port if UTXBUF0
empty//
{
TXBUF1=read_data;
}
return read_data;
}
Hi,

I think your problem is that you're not waiting till the dummy write byte for RX is flushed
through properly, before reading RXBUF0.
Don't wait for RXIFG0 to set, wait for TXIFG0 to set - indicating that the RXd byte (if any)
has been clocked in to the F149 - and then read RXBUF0.
(RXIFG0 will still be set from the previous transaction, hence you're not waiting for the SPI RX
transaction to complete)
Because SPI always _exchanges_ 2 bytes in a bus transaction, you must assume data has been
received, whether the slave actually provided one or not.

PS : be careful with your commenting style. IMO it's better to use C++ style solely or else use
/* .... */ style.

Best Regards,
Kris

-----Original Message-----
From: m... [mailto:m...] On Behalf Of europus
Sent: Wednesday, 31 October 2007 10:25 AM
To: m...
Subject: [msp430] F149 SPI issue with Serial EEPROM
Hi all ,

I have F149 on SPI bus with AT25160A SPI EEPROM....My
problem is, inspite of all signals good in timing etc...I am not able to
receive a character in RXBUF0......I can see everything good on
oscilloscope and see that 0X41...i.e 'A' is output from EEPROM but
RXBUF0 receives 0....Does anyone have any clue to this issue?? Thanks in
advance....Driver that i am using is attached....

unsigned short e2prom_read(unsigned int read_addr)
{
int delay;
short read_data;
short read_high_addr;
short read_low_addr;
read_addr=0X0010;
P3OUT ^= 0X10; //EEPROM CS3 low//
P2OUT |= 0X80; //0-20mV DAC unselect//
P3OUT |= 0X01; //P3.0 Main DAC deselect//
read_high_addr = (read_addr & 0XFF00)/0X100;//Separate High Byte //
read_low_addr = (read_addr & 0X00FF);//Separate Low Byte//
while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
{
TXBUF0=0X03; //Instruction for Reading EEPROM//
}
while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
{
TXBUF0=read_high_addr; //Write high byte of address for EEPROM//
}
while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
{
TXBUF0=read_low_addr; //Write high byte of address for EEPROM//
}
while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
{
TXBUF0=0X00; //Dummy Write for receive clock//
}
while (!(IFG1 & URXIFG0));
{
read_data=RXBUF0; //Assign data to variable//
}
for(delay=0;delay<240;delay++);
P3OUT |= 0X10; //EEPROM CS3 high (deselect)//
while (!(IFG2 & UTXIFG1)); //Transmit digit1 to serial port if UTXBUF0
empty//
{
TXBUF1=read_data;
}
return read_data;
}
Yeah, San Andreas is a pain all right :-) Was it big tremors ?
Hopefully not a sign of a repeat of 1989 :-(
What's your initialisation like on USART ? Is the RX enabled properly ?
It's bizarre that RXIFG0 asserted. Are you sure that you could see the 0x41 on the bus, and that
this comes from the EEPROM ? This established of course that the EEPROM indeed is responding to
the command.
Or IOW where did the 0x41 come from ? The EEPROM I presume.
The last possibility is that you've initialised into the wrong SPI Mode (IIRC Mode 0 & 3 are most
common). Perhaps, else double check that clock polarity and phase are correct.

If you still have trouble I can post or Email directly some functions that init, read and write
SPI bytes at lowest level to ensure your HW is OK.

Best Regards,
Kris

-----Original Message-----
From: m... [mailto:m...] On Behalf Of alex ander
Sent: Wednesday, 31 October 2007 2:10 PM
To: m...
Subject: RE: [msp430] F149 SPI issue with Serial EEPROM

Thanks a lot kris.....I tried what you suggested .....But it didn;t work.....RXBUF still reads
0X00.....and moreover there was a massive tremors of earthquake here in Bay area....so talk to you
tomorrow....thanks again....

Microbit wrote: Hi,

I think your problem is that you're not waiting till the dummy write byte for RX is flushed
through properly, before reading RXBUF0.
Don't wait for RXIFG0 to set, wait for TXIFG0 to set - indicating that the RXd byte (if any)
has been clocked in to the F149 - and then read RXBUF0.
(RXIFG0 will still be set from the previous transaction, hence you're not waiting for the SPI RX
transaction to complete)
Because SPI always _exchanges_ 2 bytes in a bus transaction, you must assume data has been
received, whether the slave actually provided one or not.

PS : be careful with your commenting style. IMO it's better to use C++ style solely or else use
/* .... */ style.

Best Regards,
Kris
Yeah like you must have read now.....5.7 richter :).....so we ran out of our offices on streets.....no damage etc....We initially thought of some 18 footer bumping across the bump.....but we soon realised it wasn;t so since the tremors lasted almost 25-30 seconds....Anyway , back to work.....so i will post the init routine below ......The 0X41 that i see oscilloscope is on SO (output pin of EEPROM) that is connected to P3.2(MISO0)....and that 0X41 is the value i wrote into EEPROM using write function . I tried changing the value to 0X55 and i could see a nice bust of 01010101....and also other values change correspondingly but reading !!.:(.......
The mode is exactly what i thought of but will write correctly then and still not read.....I am using No clock delay and rising edge of clock so this becomes Mode 0 i guess?? and EEPROM data sheet says it is MODE 0 and MODE 3 compatible...so MODE0 i guess should be ok....what do you say.....??? I am confused as hell.....I will send init routine and possibly write ......thanks again for your help......

void serial_init_usart0()
{
UCTL0=0x16; // 8 bit char , SPI Mode ,USART in master mode (0x16)//
UTCTL0=0X12; //SSEL0.0 => BRCLKLK , 3 pin SPI , Clock Pol=rising edge ,(0X12)//
URCTL0=0x00; //URXEIE0
U0BR1=0x00; //Bit rate divisor for 6MHz clk input//
U0BR0=0x34; //Bit rate divisor for 6MHz clk input (0X45)//
UMCTL0=0xAA; //Modulation count for post decimal adjustment (0X00)//
}

void e2prom_write(unsigned int write_addr,unsigned char write_data)
{
int delay;
unsigned char write_high_addr;
unsigned char write_low_addr;
write_addr=0X0010;
write_data=0X55;
P2OUT |= 0X80; //0-20mV DAC unselect//
P3OUT |= 0X01; //P3.0 Main DAC deselect//
write_high_addr = (write_addr & 0XFF00)/0X100;//Separate High Byte //
write_low_addr = (write_addr & 0X00FF);//Separate Low Byte//
P3OUT &=~ 0X10; //EEPROM CS3 low//
while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
{
TXBUF0=0X06; //Write Enable for EEPROM (0X60)//
}
for(delay=0;delay<100;delay++);
P3OUT |= 0X10; //EEPROM CS3 high//
P3OUT &=~ 0X10; //EEPROM CS3 low//
while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
{
TXBUF0=0X02; //Instruction for writting to EEPROM (0X02)//
}
while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
{
TXBUF0=write_high_addr; //Write high byte of address for EEPROM//
}
while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
{
TXBUF0=write_low_addr; //Write high byte of address for EEPROM//
}
while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
{
TXBUF0=write_data; //Write high byte of address for EEPROM//
}
for(delay=0;delay<200;delay++);
P3OUT |= 0X10; //EEPROM CS3 high//
P3OUT &=~ 0X10; //EEPROM CS3 low//
while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
{
TXBUF0=0X04; //Write disable for EEPROM (0X40)//
}
for(delay=0;delay<100;delay++);
P3OUT |= 0X10; //EEPROM CS3 high (deselect)//
while (!(IFG2 & UTXIFG1)); //Transmit digit1 to serial port if UTXBUF1 empty//
{
TXBUF1=write_data;
}
}

Microbit wrote:
Yeah, San Andreas is a pain all right :-) Was it big tremors ?
Hopefully not a sign of a repeat of 1989 :-(
What's your initialisation like on USART ? Is the RX enabled properly ?
It's bizarre that RXIFG0 asserted. Are you sure that you could see the 0x41 on the bus, and that
this comes from the EEPROM ? This established of course that the EEPROM indeed is responding to
the command.
Or IOW where did the 0x41 come from ? The EEPROM I presume.
The last possibility is that you've initialised into the wrong SPI Mode (IIRC Mode 0 & 3 are most
common). Perhaps, else double check that clock polarity and phase are correct.

If you still have trouble I can post or Email directly some functions that init, read and write
SPI bytes at lowest level to ensure your HW is OK.

Best Regards,
Kris

-----Original Message-----
From: m... [mailto:m...] On Behalf Of alex ander
Sent: Wednesday, 31 October 2007 2:10 PM
To: m...
Subject: RE: [msp430] F149 SPI issue with Serial EEPROM

Thanks a lot kris.....I tried what you suggested .....But it didn;t work.....RXBUF still reads
0X00.....and moreover there was a massive tremors of earthquake here in Bay area....so talk to you
tomorrow....thanks again....

Microbit wrote: Hi,

I think your problem is that you're not waiting till the dummy write byte for RX is flushed
through properly, before reading RXBUF0.
Don't wait for RXIFG0 to set, wait for TXIFG0 to set - indicating that the RXd byte (if any)
has been clocked in to the F149 - and then read RXBUF0.
(RXIFG0 will still be set from the previous transaction, hence you're not waiting for the SPI RX
transaction to complete)
Because SPI always _exchanges_ 2 bytes in a bus transaction, you must assume data has been
received, whether the slave actually provided one or not.

PS : be careful with your commenting style. IMO it's better to use C++ style solely or else use
/* .... */ style.

Best Regards,
Kris

__________________________________________________
Here in Brazil we're happy we don't have earthquakes, although violence
and corruption are indeed issues...

In respect with the SPI: you could try to wait for the RX flag to set
after you send a byte to the EEPROM. Then read the byte just received or
clear the RX flag. I think this guarantees that your RX buffer will
always be ready to receive another data. This should be done every time
you send a byte to the EEPROM.

Regards,
Adriano.

alex ander wrote:

> Yeah like you must have read now.....5.7 richter :).....so we ran out
> of our offices on streets.....no damage etc....We initially thought of
> some 18 footer bumping across the bump.....but we soon realised it
> wasn;t so since the tremors lasted almost 25-30 seconds....Anyway ,
> back to work.....so i will post the init routine below ......The 0X41
> that i see oscilloscope is on SO (output pin of EEPROM) that is
> connected to P3.2(MISO0)....and that 0X41 is the value i wrote into
> EEPROM using write function . I tried changing the value to 0X55 and i
> could see a nice bust of 01010101....and also other values change
> correspondingly but reading !!.:(.......
> The mode is exactly what i thought of but will write correctly then
> and still not read.....I am using No clock delay and rising edge of
> clock so this becomes Mode 0 i guess?? and EEPROM data sheet says it
> is MODE 0 and MODE 3 compatible...so MODE0 i guess should be
> ok....what do you say.....??? I am confused as hell.....I will send
> init routine and possibly write ......thanks again for your help......
> void serial_init_usart0()
> {
> UCTL0=0x16; // 8 bit char , SPI Mode ,USART in master mode (0x16)//
> UTCTL0=0X12; //SSEL0.0 => BRCLKLK , 3 pin SPI , Clock Pol=rising
> edge ,(0X12)//
> URCTL0=0x00; //URXEIE0
> U0BR1=0x00; //Bit rate divisor for 6MHz clk input//
> U0BR0=0x34; //Bit rate divisor for 6MHz clk input (0X45)//
> UMCTL0=0xAA; //Modulation count for post decimal adjustment (0X00)//
> }
>
> void e2prom_write(unsigned int write_addr,unsigned char write_data)
> {
> int delay;
> unsigned char write_high_addr;
> unsigned char write_low_addr;
> write_addr=0X0010;
> write_data=0X55;
> P2OUT |= 0X80; //0-20mV DAC unselect//
> P3OUT |= 0X01; //P3.0 Main DAC deselect//
> write_high_addr = (write_addr & 0XFF00)/0X100;//Separate High Byte //
> write_low_addr = (write_addr & 0X00FF);//Separate Low Byte//
> P3OUT &=~ 0X10; //EEPROM CS3 low//
> while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
> {
> TXBUF0=0X06; //Write Enable for EEPROM (0X60)//
> }
> for(delay=0;delay<100;delay++);
> P3OUT |= 0X10; //EEPROM CS3 high//
> P3OUT &=~ 0X10; //EEPROM CS3 low//
> while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
> {
> TXBUF0=0X02; //Instruction for writting to EEPROM (0X02)//
> }
> while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
> {
> TXBUF0=write_high_addr; //Write high byte of address for EEPROM//
> }
> while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
> {
> TXBUF0=write_low_addr; //Write high byte of address for EEPROM//
> }
> while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
> {
> TXBUF0=write_data; //Write high byte of address for EEPROM//
> }
> for(delay=0;delay<200;delay++);
> P3OUT |= 0X10; //EEPROM CS3 high//
> P3OUT &=~ 0X10; //EEPROM CS3 low//
> while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
> {
> TXBUF0=0X04; //Write disable for EEPROM (0X40)//
> }
> for(delay=0;delay<100;delay++);
> P3OUT |= 0X10; //EEPROM CS3 high (deselect)//
> while (!(IFG2 & UTXIFG1)); //Transmit digit1 to serial port if UTXBUF1
> empty//
> {
> TXBUF1=write_data;
> }
> }
>
> Microbit > > wrote:
> Yeah, San Andreas is a pain all right :-) Was it big tremors ?
> Hopefully not a sign of a repeat of 1989 :-(
> What's your initialisation like on USART ? Is the RX enabled properly ?
> It's bizarre that RXIFG0 asserted. Are you sure that you could see the
> 0x41 on the bus, and that
> this comes from the EEPROM ? This established of course that the
> EEPROM indeed is responding to
> the command.
> Or IOW where did the 0x41 come from ? The EEPROM I presume.
> The last possibility is that you've initialised into the wrong SPI
> Mode (IIRC Mode 0 & 3 are most
> common). Perhaps, else double check that clock polarity and phase are
> correct.
>
> If you still have trouble I can post or Email directly some functions
> that init, read and write
> SPI bytes at lowest level to ensure your HW is OK.
>
> Best Regards,
> Kris
>
> -----Original Message-----
> From: m...
> [mailto:m... ] On
> Behalf Of alex ander
> Sent: Wednesday, 31 October 2007 2:10 PM
> To: m...
> Subject: RE: [msp430] F149 SPI issue with Serial EEPROM
>
> Thanks a lot kris.....I tried what you suggested .....But it didn;t
> work.....RXBUF still reads
> 0X00.....and moreover there was a massive tremors of earthquake here
> in Bay area....so talk to you
> tomorrow....thanks again....
>
> Microbit > > wrote: Hi,
>
> I think your problem is that you're not waiting till the dummy write
> byte for RX is flushed
> through properly, before reading RXBUF0.
> Don't wait for RXIFG0 to set, wait for TXIFG0 to set - indicating that
> the RXd byte (if any)
> has been clocked in to the F149 - and then read RXBUF0.
> (RXIFG0 will still be set from the previous transaction, hence you're
> not waiting for the SPI RX
> transaction to complete)
> Because SPI always _exchanges_ 2 bytes in a bus transaction, you must
> assume data has been
> received, whether the slave actually provided one or not.
>
> PS : be careful with your commenting style. IMO it's better to use C++
> style solely or else use
> /* .... */ style.
>
> Best Regards,
> Kris
>
> __________________________________________________
>
> --
> Esta mensagem foi verificada pelo sistema de antivus e
> acredita-se estar livre de perigo.
--
Esta mensagem foi verificada pelo sistema de antivus e
acredita-se estar livre de perigo.
Hi adriano ..
Thanks for your help.....I got it working late yesterday.....The issue was with
the long delay around 40uSec which i had not added after sending a dummy byte
for clock.....Once i added that delay....it started right there.......Thanks to all who
helped....

Adriano Caye wrote:
Here in Brazil we're happy we don't have earthquakes, although violence
and corruption are indeed issues...

In respect with the SPI: you could try to wait for the RX flag to set
after you send a byte to the EEPROM. Then read the byte just received or
clear the RX flag. I think this guarantees that your RX buffer will
always be ready to receive another data. This should be done every time
you send a byte to the EEPROM.

Regards,
Adriano.

alex ander wrote:

> Yeah like you must have read now.....5.7 richter :).....so we ran out
> of our offices on streets.....no damage etc....We initially thought of
> some 18 footer bumping across the bump.....but we soon realised it
> wasn;t so since the tremors lasted almost 25-30 seconds....Anyway ,
> back to work.....so i will post the init routine below ......The 0X41
> that i see oscilloscope is on SO (output pin of EEPROM) that is
> connected to P3.2(MISO0)....and that 0X41 is the value i wrote into
> EEPROM using write function . I tried changing the value to 0X55 and i
> could see a nice bust of 01010101....and also other values change
> correspondingly but reading !!.:(.......
> The mode is exactly what i thought of but will write correctly then
> and still not read.....I am using No clock delay and rising edge of
> clock so this becomes Mode 0 i guess?? and EEPROM data sheet says it
> is MODE 0 and MODE 3 compatible...so MODE0 i guess should be
> ok....what do you say.....??? I am confused as hell.....I will send
> init routine and possibly write ......thanks again for your help......
> void serial_init_usart0()
> {
> UCTL0=0x16; // 8 bit char , SPI Mode ,USART in master mode (0x16)//
> UTCTL0=0X12; //SSEL0.0 => BRCLK=ACLK , 3 pin SPI , Clock Pol=rising
> edge ,(0X12)//
> URCTL0=0x00; //URXEIE0
> U0BR1=0x00; //Bit rate divisor for 6MHz clk input//
> U0BR0=0x34; //Bit rate divisor for 6MHz clk input (0X45)//
> UMCTL0=0xAA; //Modulation count for post decimal adjustment (0X00)//
> }
>
> void e2prom_write(unsigned int write_addr,unsigned char write_data)
> {
> int delay;
> unsigned char write_high_addr;
> unsigned char write_low_addr;
> write_addr=0X0010;
> write_data=0X55;
> P2OUT |= 0X80; //0-20mV DAC unselect//
> P3OUT |= 0X01; //P3.0 Main DAC deselect//
> write_high_addr = (write_addr & 0XFF00)/0X100;//Separate High Byte //
> write_low_addr = (write_addr & 0X00FF);//Separate Low Byte//
> P3OUT &=~ 0X10; //EEPROM CS3 low//
> while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
> {
> TXBUF0=0X06; //Write Enable for EEPROM (0X60)//
> }
> for(delay=0;delay<100;delay++);
> P3OUT |= 0X10; //EEPROM CS3 high//
> P3OUT &=~ 0X10; //EEPROM CS3 low//
> while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
> {
> TXBUF0=0X02; //Instruction for writting to EEPROM (0X02)//
> }
> while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
> {
> TXBUF0=write_high_addr; //Write high byte of address for EEPROM//
> }
> while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
> {
> TXBUF0=write_low_addr; //Write high byte of address for EEPROM//
> }
> while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
> {
> TXBUF0=write_data; //Write high byte of address for EEPROM//
> }
> for(delay=0;delay<200;delay++);
> P3OUT |= 0X10; //EEPROM CS3 high//
> P3OUT &=~ 0X10; //EEPROM CS3 low//
> while (!(IFG1 & UTXIFG0)); //Transmit buffer check//
> {
> TXBUF0=0X04; //Write disable for EEPROM (0X40)//
> }
> for(delay=0;delay<100;delay++);
> P3OUT |= 0X10; //EEPROM CS3 high (deselect)//
> while (!(IFG2 & UTXIFG1)); //Transmit digit1 to serial port if UTXBUF1
> empty//
> {
> TXBUF1=write_data;
> }
> }
>
> Microbit > > wrote:
> Yeah, San Andreas is a pain all right :-) Was it big tremors ?
> Hopefully not a sign of a repeat of 1989 :-(
> What's your initialisation like on USART ? Is the RX enabled properly ?
> It's bizarre that RXIFG0 asserted. Are you sure that you could see the
> 0x41 on the bus, and that
> this comes from the EEPROM ? This established of course that the
> EEPROM indeed is responding to
> the command.
> Or IOW where did the 0x41 come from ? The EEPROM I presume.
> The last possibility is that you've initialised into the wrong SPI
> Mode (IIRC Mode 0 & 3 are most
> common). Perhaps, else double check that clock polarity and phase are
> correct.
>
> If you still have trouble I can post or Email directly some functions
> that init, read and write
> SPI bytes at lowest level to ensure your HW is OK.
>
> Best Regards,
> Kris
>
> -----Original Message-----
> From: m...
> [mailto:m... ] On
> Behalf Of alex ander
> Sent: Wednesday, 31 October 2007 2:10 PM
> To: m...
> Subject: RE: [msp430] F149 SPI issue with Serial EEPROM
>
> Thanks a lot kris.....I tried what you suggested .....But it didn;t
> work.....RXBUF still reads
> 0X00.....and moreover there was a massive tremors of earthquake here
> in Bay area....so talk to you
> tomorrow....thanks again....
>
> Microbit > > wrote: Hi,
>
> I think your problem is that you're not waiting till the dummy write
> byte for RX is flushed
> through properly, before reading RXBUF0.
> Don't wait for RXIFG0 to set, wait for TXIFG0 to set - indicating that
> the RXd byte (if any)
> has been clocked in to the F149 - and then read RXBUF0.
> (RXIFG0 will still be set from the previous transaction, hence you're
> not waiting for the SPI RX
> transaction to complete)
> Because SPI always _exchanges_ 2 bytes in a bus transaction, you must
> assume data has been
> received, whether the slave actually provided one or not.
>
> PS : be careful with your commenting style. IMO it's better to use C++
> style solely or else use
> /* .... */ style.
>
> Best Regards,
> Kris
>
> __________________________________________________
>
>
>
> --
> Esta mensagem foi verificada pelo sistema de antivus e
> acredita-se estar livre de perigo.

--
Esta mensagem foi verificada pelo sistema de antivus e
acredita-se estar livre de perigo.



__________________________________________________