Reply by georgeliu28 December 13, 20072007-12-13
Thank you Michael

I'm working on ISP(in program system) to update flash via SPI to get
data. And my MCU (MSP430f2272) device works on SPI slave model. And
the SPI transmition only 1 Byte. the host provide a 6MHz clock to
SPI. Normally. SPI transmits data fine. I can send and received data
correctly. But when I did flash updata after completed update flash
via SPI to receive data.(I check data and Flash address correctly)
and then after update completed I move the PC counter as below code
"asm("MOV #0x8000,PC")".
The SPI can not sned/receive correct data. I thank SPI should be
corrupted. So I tried to add inital SPI interface when sends or
receives data is incorrect. however. this manner doesn't work out.

And because I met that host sned data too fast cause SPI corrupt. SO
I add some delay (800 us) when host send a data after then it won't
be happened that SPI corrupt data. But this time is different, after
I move PC to 0x8000 addres and re-run it. the SPI is corrupted.

By the way, I have ignored update flash update part which contain SPI
send/receive and update fucntion I write to flash at address start
0xA000 to 0xAFFF. And the flash update functon is only update main
fucntion which from 0x8000 to 0x8FFF and interrupt vector 0xffc0 to
0xffff two parts. And the update function I don't use SPI interrupt
function.

So does any code I can add or prevent SPI sned/receive data
corruption.

Thank you

--- In m..., mkusch@... wrote:
>
> You need to add a lot more description of your problem to be able
to get any help.
> RX and TX hardware Buffer is only 1 byte long.
> What is the kind of corruption? are the bytes being corrupted
('hardware' corruption due to too fast clock) or are you missing
entire bytes ('software' corruption due to too slow RX Buffer
reading)?.
>
> Is the MSP slave or master in SPI communication?
>
> How do you know data is invalid?
>
> Michael Kusch
>
> Dear all,
> >
> > I got a question about SPI communication. And my MCU's
(MSP430f2272)
> >SPI can not read/write SPI's RX/TX buffer correctly. The conditon
may
> >be the host transmit speed too fast or fill in bigger then RX/TX
buffer
> >size cause it.
> >
> >So I wonder If my MCU's RX/TX buffer can not get correct data,
does
> >there are anyway (any code protection)can help correct SPI
read/write
> >data. Cause I have tried re-initial SPI interface when data is
invaild.
> >But It seen not help.
> >
> >thank you
> >
>

Beginning Microcontrollers with the MSP430

Reply by tintronic December 12, 20072007-12-12
Please try to get some help to explain your problem. I know english
isn't your primary language (it isn't mine either), but your writing
is too confusing to follow.
Let me see if I understand correctly:

- You want to update your firmware via SPI.
- You store the new firmware at address 0x8000.
- You have verified this process and the new firmware is being
correctly stored. No data corruption here. This means SPI is not
running too fast.
* Now you want to start program execution for this new firmware.
That works, but the data you are now reciving on SPI is corrupt.

This statement I don't understand: " So I tried to add inital SPI
interface when sends or receives data is incorrect". Nor do I
understand anything you are trying to say after that. Maybe you should
write it in your own language and THEN post it in english.

Your MSP is SPI slave, so it cannot reset this interface whenever it
wants to, because the Master may be transmitting, causing the slave to
start reciving data in the middle of a byte. This means your byte
receptions will have lost syncronism. You will be getting the bits in
the correct order, but the byte boundaries will be wrong.

SPI Slaves usually have a CS (Chips select) input. CS is for both
selecting the device and syncronizing byte transmition. When CS is
deselected, any current transfer is aborted and following clock cycles
are ignored, that is, SPI stays in a reset state. On a #CS to CS
transition the SPI interface is enabled, leaving the reset state. SPI
Master must allow a time for the slave SPI to get out of reset and be
ready to recive clock cycles. This is the way bytes are sincronized
between two SPI devices.

I recomend you add a CS input to your MSP. Activate CS when you start
to transfer a bunch of data and then deactivate it. There is nothing
the SPI slave can do once it starts to get corrupted data, other than
wait for another bunch of data after the next #CS to CS transition.

Maybe your new firmware includes a SPI initialization routine, which
happens in the middle of an SPI transfer, causing to screw up the SPI
byte sync.

Regards,
Michael Kusch

--- In m..., "georgeliu28" wrote:
>
> Thank you Michael
>
> I'm working on ISP(in program system) to update flash via SPI to get
> data. And my MCU (MSP430f2272) device works on SPI slave model. And
> the SPI transmition only 1 Byte. the host provide a 6MHz clock to
> SPI. Normally. SPI transmits data fine. I can send and received data
> correctly. But when I did flash updata after completed update flash
> via SPI to receive data.(I check data and Flash address correctly)
> and then after update completed I move the PC counter as below code
> "asm("MOV #0x8000,PC")".
> The SPI can not sned/receive correct data. I thank SPI should be
> corrupted. So I tried to add inital SPI interface when sends or
> receives data is incorrect. however. this manner doesn't work out.
>
> And because I met that host sned data too fast cause SPI corrupt. SO
> I add some delay (800 us) when host send a data after then it won't
> be happened that SPI corrupt data. But this time is different, after
> I move PC to 0x8000 addres and re-run it. the SPI is corrupted.
>
> By the way, I have ignored update flash update part which contain SPI
> send/receive and update fucntion I write to flash at address start
> 0xA000 to 0xAFFF. And the flash update functon is only update main
> fucntion which from 0x8000 to 0x8FFF and interrupt vector 0xffc0 to
> 0xffff two parts. And the update function I don't use SPI interrupt
> function.
>
> So does any code I can add or prevent SPI sned/receive data
> corruption.
>
> Thank you
>
>
>
> --- In m..., mkusch@ wrote:
> >
> > You need to add a lot more description of your problem to be able
> to get any help.
> > RX and TX hardware Buffer is only 1 byte long.
> > What is the kind of corruption? are the bytes being corrupted
> ('hardware' corruption due to too fast clock) or are you missing
> entire bytes ('software' corruption due to too slow RX Buffer
> reading)?.
> >
> > Is the MSP slave or master in SPI communication?
> >
> > How do you know data is invalid?
> >
> > Michael Kusch
> >
> > Dear all,
> > >
> > > I got a question about SPI communication. And my MCU's
> (MSP430f2272)
> > >SPI can not read/write SPI's RX/TX buffer correctly. The conditon
> may
> > >be the host transmit speed too fast or fill in bigger then RX/TX
> buffer
> > >size cause it.
> > >
> > >So I wonder If my MCU's RX/TX buffer can not get correct data,
> does
> > >there are anyway (any code protection)can help correct SPI
> read/write
> > >data. Cause I have tried re-initial SPI interface when data is
> invaild.
> > >But It seen not help.
> > >
> > >thank you
> > >
> > >
>
Reply by georgeliu28 December 11, 20072007-12-11
Dear all,

I got a question about SPI communication. And my MCU's (MSP430f2272)
SPI can not read/write SPI's RX/TX buffer correctly. The conditon may
be the host transmit speed too fast or fill in bigger then RX/TX buffer
size cause it.

So I wonder If my MCU's RX/TX buffer can not get correct data, does
there are anyway (any code protection)can help correct SPI read/write
data. Cause I have tried re-initial SPI interface when data is invaild.
But It seen not help.

thank you