Hi,
yes, you produce receive clocks by sending dummy bytes.
Serial output and input have buffer registers that may introduce
confusion with SPI. For example on MSP430 you can write 2 leading bytes
of SPI sequence to serial output register back-to-back without checking
anything. But at the end of the sequence you have to be careful not to
destroy ongoing operation by disabling CS too early. Up to 16 bit clocks
may be waiting for completion.
Please check that the Chip Select is generated long enough to complete
sending the opcode and address and some extra NULL bytes before
receiving the data.
The ATMEL dataflash is a nice device and easy to use, yet special in
that it replies to addressable functions only after some extra delay
bytes. If i remember correctly you may need up to 9 x 8bit clocks before
you have the first data byte. So the SPI clock should really be as high
as possible.
The best way is to make a small test program that loops your SPI
functions. Then you look at the signals with a multichannel scope and
compare them to the ATMEL AT45DB041B data sheet timing diagrams.
Good luck,
D. Teuchert
Krzysztof Gawry wrote:
> Hi,
> I check you propose. I sets up CKPL (bit 6) in U0TCTL register.
> Unfornetley this don't help.
>
> Question: there is another way to generate clock signal on SCK pin,
> different than sending dummy byte when i read from SPI?
> I need to send dummy byte to get read next byte.
> I can only read even bytes from memory buffer. Odd bytes are lost.
> Why? I guess that this might be bad clocking.
>
> Regards
> Krzysztof
>
> --- In msp430@msp4..., Dieter Teuchert <dieter@c...> wrote:
> > Hi,
> > another proposal:
> >
> > I remember that the clock phase of SPI is something you have to
> think
> > about. If i remember right, there are two modes called SPI mode 1
> and
> > mode 3.
> >
> > Maybe your system works at slow speed even with wrong clock phase,
> > because for some reason data setup time is met.
> >
> > I would try inverting the clock phase. That is one bit in a SPI
> > configuration register.
> > Regards
> > D. Teuchert
> >
> >
> > Krzysztof Gawry wrote:
> >
> > > Hi Martin
> > >
> > > Thanx for response.
> > >
> > > Unfornetley that what you say me, doasn't help. ;-(
> > >
> > > I pull-up (over 47kOhm resistor) SCK, MOSI and MISO to 3,3V, but
> this
> > > don't help too.
> > > Still can communicate only at lower speeds.
> > > Now, i completly don't know what to do. ;-(
> > >
> > > Strange thing!, when set up SPI to ~1,2MHz and slow down MCLK
> clock I
> > > need to slow down SMCLK (SPI clocked from SMCLK) too to get
> > > communication, why??
> > >
> > > Regards
> > > Krzysztof
> > >
> > > --- In msp430@msp4..., "mypwd_martin"
<kohler@h...> wrote:
> > > > hello Krzysztof,
> > > >
> > > > many problems of USART/SPI are caused from an unitialized
> > > > statemachine.
> > > > You have to reset the serial statemachine after SPI
> initialization.
> > > >
> > > >
> > > > UCTL0 &= ~SWRST; // Initalize USART0/SPI0 state machine
> > > >
> > > > Martin
> > > >
> > > >
> > > > --- In msp430@msp4..., Krzysztof Gawry
> > > > <kgprogramer@y...>
> > > > wrote:
> > > > > Hi All,
> > > > >
> > > > > I've problem with max SPI bus speed,
> > > > > I connect AT45DB041B (Atmel's pdf says:
> > > > > " 20 MHz Max Clock Frequency" p.1 of
doc1918.pdf)
> > > > > and:
> > > > >
> > > > > couple code of SPI initialization :
> > > > > //---
> > > > > BCSCTL1 &= ~XT2OFF; // XT2on
> > > > > BCSCTL2 |= SELM1+SELS; // MCLK = LFXT1 (safe)
> > > > > ME1 = USPIE0; // Enable SPI mode
> > > > > UTCTL0 = CKPH+SSEL1+SSEL0+STC; // SMCLK,
3-pin mode
> > > > > UCTL0 = CHAR+SYNC+MM; // 8-bit SPI Master
> > > > > UBR00 = 0x02;
> > > > > UBR10 = 0x00;
> > > > > UMCTL0 = 0x00;
> > > > > P3SEL = 0x0E;
> > > > > P3DIR = 0x1B;
> > > > > //---
> > > > >
> > > > > external CPU clock is 7,3728MHz at XT2.
> > > > > At SPI speed 3,6864MHz (7,3728MHz / UBR00=2), external
spi
> flash
> > > > > memory don't work, at SPI speed 1,2288MHz
(7,3728MHz /
> UBR00=6),
> > > > > AT45DB041B work preety, but this speed is not enought
speed
> for
> > > me.
> > > > >
> > > > > I do an experiment and connect 22,184MHz quartz to XT2
of
> F149 uC
> > > > > (nice thing, unexplectly MSP430F149 preety work at this
> speed),
> > > but
> > > > I
> > > > > still have problems with AT45... <-> SPI F149:
> > > > >
> > > > > At SPI speed 11059200Hz (UBR00=2), AT45 doasn't
work, at speed
> > > > > ~1,4745MHz (UBR00) Atmel's flash starts work ok.
> > > > >
> > > > > Why I can't get it faster???
> > > > >
> > > > > (Question, does anybody test max speed of external
quartz at
> > > XT2?,
> > > > I
> > > > > have run MSP430F149 at 22,184MHz, but I don't know
how to
> test it
> > > > for
> > > > > errors at speeds higher than 8MHz.)
> > >
> > >
> > >
> > > .
> > >
> > >
> > >
> > >
> > > ------------------------------
> ------
> > > *>.
> > >
> > >
> >
> > --
> > Dipl.-Phys. Dieter Teuchert
> > Software und Systeme
> > Postanschrift:
> >
> >
> >
> > Telefon:
> > Telefax:
> > EMail Firma:
> > EMail perslich:
> > Internet:
> > Rommelstr. 6
> > D-76571 Gaggenau
> > Germany
> >
> > +49 7225 989253
> > +49 7225 989254
> > info@c...
> > dieter@c...
> > _http://www.cadt.de_
>
>
>
> .
>
>
>
>
>
> *>.
>
>
--
Dipl.-Phys. Dieter Teuchert
Software und Systeme
Postanschrift:
Telefon:
Telefax:
EMail Firma:
EMail perslich:
Internet:
Rommelstr. 6
D-76571 Gaggenau
Germany
+49 7225 989253
+49 7225 989254
info@info...
dieter@diet...
_http://www.cadt.de_
Hi,
I check you propose. I sets up CKPL (bit 6) in U0TCTL register.
Unfornetley this don't help.
Question: there is another way to generate clock signal on SCK pin,
different than sending dummy byte when i read from SPI?
I need to send dummy byte to get read next byte.
I can only read even bytes from memory buffer. Odd bytes are lost.
Why? I guess that this might be bad clocking.
Regards
Krzysztof
--- In msp430@msp4..., Dieter Teuchert <dieter@c...> wrote:
> Hi,
> another proposal:
>
> I remember that the clock phase of SPI is something you have to
think
> about. If i remember right, there are two modes
called SPI mode 1
and
> mode 3.
>
> Maybe your system works at slow speed even with wrong clock phase,
> because for some reason data setup time is met.
>
> I would try inverting the clock phase. That is one bit in a SPI
> configuration register.
> Regards
> D. Teuchert
>
>
> Krzysztof Gawry wrote:
>
> > Hi Martin
> >
> > Thanx for response.
> >
> > Unfornetley that what you say me, doasn't help. ;-(
> >
> > I pull-up (over 47kOhm resistor) SCK, MOSI and MISO to 3,3V, but
this
> > don't help too.
> > Still can communicate only at lower speeds.
> > Now, i completly don't know what to do. ;-(
> >
> > Strange thing!, when set up SPI to ~1,2MHz and slow down MCLK
clock I
> > need to slow down SMCLK (SPI clocked from
SMCLK) too to get
> > communication, why??
> >
> > Regards
> > Krzysztof
> >
> > --- In msp430@msp4..., "mypwd_martin" <kohler@h...>
wrote:
> > > hello Krzysztof,
> > >
> > > many problems of USART/SPI are caused from an unitialized
> > > statemachine.
> > > You have to reset the serial statemachine after SPI
initialization.
> > >
> > >
> > > UCTL0 &= ~SWRST; // Initalize USART0/SPI0 state machine
> > >
> > > Martin
> > >
> > >
> > > --- In msp430@msp4..., Krzysztof Gawry
> > > <kgprogramer@y...>
> > > wrote:
> > > > Hi All,
> > > >
> > > > I've problem with max SPI bus speed,
> > > > I connect AT45DB041B (Atmel's pdf says:
> > > > " 20 MHz Max Clock Frequency" p.1 of doc1918.pdf)
> > > > and:
> > > >
> > > > couple code of SPI initialization :
> > > > //---
> > > > BCSCTL1 &= ~XT2OFF; // XT2on
> > > > BCSCTL2 |= SELM1+SELS; // MCLK = LFXT1 (safe)
> > > > ME1 = USPIE0; // Enable SPI mode
> > > > UTCTL0 = CKPH+SSEL1+SSEL0+STC; // SMCLK, 3-pin
mode
> > > > UCTL0 = CHAR+SYNC+MM; // 8-bit SPI Master
> > > > UBR00 = 0x02;
> > > > UBR10 = 0x00;
> > > > UMCTL0 = 0x00;
> > > > P3SEL = 0x0E;
> > > > P3DIR = 0x1B;
> > > > //---
> > > >
> > > > external CPU clock is 7,3728MHz at XT2.
> > > > At SPI speed 3,6864MHz (7,3728MHz / UBR00=2), external spi
flash
> > > > memory don't work, at SPI
speed 1,2288MHz (7,3728MHz /
UBR00=6),
> > > > AT45DB041B work preety, but this
speed is not enought speed
for
> > me.
> > > >
> > > > I do an experiment and connect 22,184MHz quartz to XT2 of
F149 uC
> > > > (nice thing, unexplectly MSP430F149
preety work at this
speed),
> > but
> > > I
> > > > still have problems with AT45... <-> SPI F149:
> > > >
> > > > At SPI speed 11059200Hz (UBR00=2), AT45 doasn't work,
at speed
> > > > ~1,4745MHz (UBR00) Atmel's flash starts work ok.
> > > >
> > > > Why I can't get it faster???
> > > >
> > > > (Question, does anybody test max speed of external quartz at
> > XT2?,
> > > I
> > > > have run MSP430F149 at 22,184MHz, but I don't know how
to
test it
> > > for
> > > > errors at speeds higher than 8MHz.)
> >
> >
> >
> > .
> >
> >
> >
> >
> > ------------------------------
------
> > *>.
> >
> >
>
> --
> Dipl.-Phys. Dieter Teuchert
> Software und Systeme
> Postanschrift:
>
>
>
> Telefon:
> Telefax:
> EMail Firma:
> EMail perslich:
> Internet:
> Rommelstr. 6
> D-76571 Gaggenau
> Germany
>
> +49 7225 989253
> +49 7225 989254
> info@c...
> dieter@c...
> _http://www.cadt.de_
Reply by Ing. Morra Antonio●April 1, 20042004-04-01
Hi Krzysztof!,
I had similar problems with a DIFFERENT microprocessor and the same Atmel
memory.
To keep it short I was not able to reach the stated clock speed for the Atmel.
In that case I was obliged to limit speed to 3.5 MHz.
I do not remember exactly what the reason was, but it has to do with the
way you shall read the Atmel specification.
IIRC the timing for the two clock phases are NOT the same. You can achieve
maximum speed only if you clock the thing with an asymmetrical clock.
Again, this is one of those "if I remember correctly" kind of things,
but
it may be worth for you to go check the ATMEL specification with this in mind.
If I am right you cannot do much to improve your speed.
Regards
A.Morra
Reply by Dieter Teuchert●April 1, 20042004-04-01
Hi,
another proposal:
I remember that the clock phase of SPI is something you have to think
about. If i remember right, there are two modes called SPI mode 1 and
mode 3.
Maybe your system works at slow speed even with wrong clock phase,
because for some reason data setup time is met.
I would try inverting the clock phase. That is one bit in a SPI
configuration register.
Regards
D. Teuchert
Krzysztof Gawry wrote:
> Hi Martin
>
> Thanx for response.
>
> Unfornetley that what you say me, doasn't help. ;-(
>
> I pull-up (over 47kOhm resistor) SCK, MOSI and MISO to 3,3V, but this
> don't help too.
> Still can communicate only at lower speeds.
> Now, i completly don't know what to do. ;-(
>
> Strange thing!, when set up SPI to ~1,2MHz and slow down MCLK clock I
> need to slow down SMCLK (SPI clocked from SMCLK) too to get
> communication, why??
>
> Regards
> Krzysztof
>
> --- In msp430@msp4..., "mypwd_martin" <kohler@h...> wrote:
> > hello Krzysztof,
> >
> > many problems of USART/SPI are caused from an unitialized
> > statemachine.
> > You have to reset the serial statemachine after SPI initialization.
> >
> >
> > UCTL0 &= ~SWRST; // Initalize USART0/SPI0 state machine
> >
> > Martin
> >
> >
> > --- In msp430@msp4..., Krzysztof Gawry
> > <kgprogramer@y...>
> > wrote:
> > > Hi All,
> > >
> > > I've problem with max SPI bus speed,
> > > I connect AT45DB041B (Atmel's pdf says:
> > > " 20 MHz Max Clock Frequency" p.1 of doc1918.pdf)
> > > and:
> > >
> > > couple code of SPI initialization :
> > > //---
> > > BCSCTL1 &= ~XT2OFF; // XT2on
> > > BCSCTL2 |= SELM1+SELS; // MCLK = LFXT1 (safe)
> > > ME1 = USPIE0; // Enable SPI mode
> > > UTCTL0 = CKPH+SSEL1+SSEL0+STC; // SMCLK, 3-pin mode
> > > UCTL0 = CHAR+SYNC+MM; // 8-bit SPI Master
> > > UBR00 = 0x02;
> > > UBR10 = 0x00;
> > > UMCTL0 = 0x00;
> > > P3SEL = 0x0E;
> > > P3DIR = 0x1B;
> > > //---
> > >
> > > external CPU clock is 7,3728MHz at XT2.
> > > At SPI speed 3,6864MHz (7,3728MHz / UBR00=2), external spi flash
> > > memory don't work, at SPI speed 1,2288MHz (7,3728MHz /
UBR00=6),
> > > AT45DB041B work preety, but this speed is not enought speed for
> me.
> > >
> > > I do an experiment and connect 22,184MHz quartz to XT2 of F149 uC
> > > (nice thing, unexplectly MSP430F149 preety work at this speed),
> but
> > I
> > > still have problems with AT45... <-> SPI F149:
> > >
> > > At SPI speed 11059200Hz (UBR00=2), AT45 doasn't work, at
speed
> > > ~1,4745MHz (UBR00) Atmel's flash starts work ok.
> > >
> > > Why I can't get it faster???
> > >
> > > (Question, does anybody test max speed of external quartz at
> XT2?,
> > I
> > > have run MSP430F149 at 22,184MHz, but I don't know how to
test it
> > for
> > > errors at speeds higher than 8MHz.)
>
>
>
> .
>
>
>
>
>
> *>.
>
>
--
Dipl.-Phys. Dieter Teuchert
Software und Systeme
Postanschrift:
Telefon:
Telefax:
EMail Firma:
EMail perslich:
Internet:
Rommelstr. 6
D-76571 Gaggenau
Germany
+49 7225 989253
+49 7225 989254
info@info...
dieter@diet...
_http://www.cadt.de_
Reply by ●March 31, 20042004-03-31
Hi Martin
Thanx for response.
Unfornetley that what you say me, doasn't help. ;-(
I pull-up (over 47kOhm resistor) SCK, MOSI and MISO to 3,3V, but this
don't help too.
Still can communicate only at lower speeds.
Now, i completly don't know what to do. ;-(
Strange thing!, when set up SPI to ~1,2MHz and slow down MCLK clock I
need to slow down SMCLK (SPI clocked from SMCLK) too to get
communication, why??
Regards
Krzysztof
--- In msp430@msp4..., "mypwd_martin" <kohler@h...> wrote:
> hello Krzysztof,
>
> many problems of USART/SPI are caused from an unitialized
> statemachine.
> You have to reset the serial statemachine after SPI initialization.
>
>
> UCTL0 &= ~SWRST; // Initalize USART0/SPI0 state machine
>
> Martin
>
>
> --- In msp430@msp4..., Krzysztof Gawry
> <kgprogramer@y...>
> wrote:
> > Hi All,
> >
> > I've problem with max SPI bus speed,
> > I connect AT45DB041B (Atmel's pdf says:
> > " 20 MHz Max Clock Frequency" p.1 of doc1918.pdf)
> > and:
> >
> > couple code of SPI initialization :
> > //---
> > BCSCTL1 &= ~XT2OFF; // XT2on
> > BCSCTL2 |= SELM1+SELS; // MCLK = LFXT1 (safe)
> > ME1 = USPIE0; // Enable SPI mode
> > UTCTL0 = CKPH+SSEL1+SSEL0+STC; // SMCLK, 3-pin mode
> > UCTL0 = CHAR+SYNC+MM; // 8-bit SPI Master
> > UBR00 = 0x02;
> > UBR10 = 0x00;
> > UMCTL0 = 0x00;
> > P3SEL = 0x0E;
> > P3DIR = 0x1B;
> > //---
> >
> > external CPU clock is 7,3728MHz at XT2.
> > At SPI speed 3,6864MHz (7,3728MHz / UBR00=2), external spi flash
> > memory don't work, at SPI speed 1,2288MHz (7,3728MHz / UBR00=6),
> > AT45DB041B work preety, but this speed is not enought speed for
me.
> >
> > I do an experiment and connect 22,184MHz quartz to XT2 of F149 uC
> > (nice thing, unexplectly MSP430F149 preety work at this speed),
but
> I
> > still have problems with AT45... <-> SPI F149:
> >
> > At SPI speed 11059200Hz (UBR00=2), AT45 doasn't work, at speed
> > ~1,4745MHz (UBR00) Atmel's flash starts work ok.
> >
> > Why I can't get it faster???
> >
> > (Question, does anybody test max speed of external quartz at
XT2?,
> I
> > have run MSP430F149 at 22,184MHz, but I don't know how to test it
> for
> > errors at speeds higher than 8MHz.)
Reply by mypwd_martin●March 31, 20042004-03-31
hello Krzysztof,
many problems of USART/SPI are caused from an unitialized
statemachine.
You have to reset the serial statemachine after SPI initialization.
UCTL0 &= ~SWRST; // Initalize USART0/SPI0 state machine
Martin
--- In msp430@msp4..., Krzysztof Gawry
<kgprogramer@y...>
wrote:
> Hi All,
>
> I've problem with max SPI bus speed,
> I connect AT45DB041B (Atmel's pdf says:
> " 20 MHz Max Clock Frequency" p.1 of doc1918.pdf)
> and:
>
> couple code of SPI initialization :
> //---
> BCSCTL1 &= ~XT2OFF; // XT2on
> BCSCTL2 |= SELM1+SELS; // MCLK = LFXT1 (safe)
> ME1 = USPIE0; // Enable SPI mode
> UTCTL0 = CKPH+SSEL1+SSEL0+STC; // SMCLK, 3-pin mode
> UCTL0 = CHAR+SYNC+MM; // 8-bit SPI Master
> UBR00 = 0x02;
> UBR10 = 0x00;
> UMCTL0 = 0x00;
> P3SEL = 0x0E;
> P3DIR = 0x1B;
> //---
>
> external CPU clock is 7,3728MHz at XT2.
> At SPI speed 3,6864MHz (7,3728MHz / UBR00=2), external spi flash
> memory don't work, at SPI speed 1,2288MHz (7,3728MHz / UBR00=6),
> AT45DB041B work preety, but this speed is not enought speed for me.
>
> I do an experiment and connect 22,184MHz quartz to XT2 of F149 uC
> (nice thing, unexplectly MSP430F149 preety work at this speed), but
I
> still have problems with AT45... <-> SPI
F149:
>
> At SPI speed 11059200Hz (UBR00=2), AT45 doasn't work, at speed
> ~1,4745MHz (UBR00) Atmel's flash starts work ok.
>
> Why I can't get it faster???
>
> (Question, does anybody test max speed of external quartz at XT2?,
I
> have run MSP430F149 at 22,184MHz, but I don't
know how to test it
for
> errors at speeds higher than 8MHz.)
Reply by ●March 31, 20042004-03-31
Hi All,
I've problem with max SPI bus speed,
I connect AT45DB041B (Atmel's pdf says:
" 20 MHz Max Clock Frequency" p.1 of doc1918.pdf)
and:
couple code of SPI initialization :
//---
BCSCTL1 &= ~XT2OFF; // XT2on
BCSCTL2 |= SELM1+SELS; // MCLK = LFXT1 (safe)
ME1 = USPIE0; // Enable SPI mode
UTCTL0 = CKPH+SSEL1+SSEL0+STC; // SMCLK, 3-pin mode
UCTL0 = CHAR+SYNC+MM; // 8-bit SPI Master
UBR00 = 0x02;
UBR10 = 0x00;
UMCTL0 = 0x00;
P3SEL = 0x0E;
P3DIR = 0x1B;
//---
external CPU clock is 7,3728MHz at XT2.
At SPI speed 3,6864MHz (7,3728MHz / UBR00=2), external spi flash
memory don't work, at SPI speed 1,2288MHz (7,3728MHz / UBR00=6),
AT45DB041B work preety, but this speed is not enought speed for me.
I do an experiment and connect 22,184MHz quartz to XT2 of F149 uC
(nice thing, unexplectly MSP430F149 preety work at this speed), but I
still have problems with AT45... <-> SPI F149:
At SPI speed 11059200Hz (UBR00=2), AT45 doasn't work, at speed
~1,4745MHz (UBR00) Atmel's flash starts work ok.
Why I can't get it faster???
(Question, does anybody test max speed of external quartz at XT2?, I
have run MSP430F149 at 22,184MHz, but I don't know how to test it for
errors at speeds higher than 8MHz.)