I'm not experienced in SPI usage in MSP430, but I haven't noticed
following things:
1) SWRST flag in U1CTL is not disabled in your sources (probably
the "while((IFG1 & UTXIFG1));" waits endless)
2) Your app treats the reading & writing from/to RX/TX USART buffers as
blocking ones - those are not !!. When you want to make blocking reads
and writes you must waits for apropriate flags to change: TXEPT in
U1TCTL and URXIFG1 in IFG2.
3) By the way: UTXIFG1 flag is not in register IFG1 !!! (at least not in
x169)
4) Prepare a JTAG for yourself and use it together with gdb - it makes
the work really simpler.
regards,
W liście z śro, 18-08-2004, godz. 19:18, Ian Bobbitt pisze:
> Hello,
>
> I am trying to interface a MSP430F169 to an Atmel AT45DB021B flash. As a
> first attempt, I am trying to read the status register, which contains a
> part-specific bit string for size determination, as well as a busy indicator.
> I have the data lines on USART1, and /CS on P3.0. I have tried the
> following code to read from the part and output the register on P1, but have
> been unsuccessful thus far. This is my first MSP430 project. What am I doing
> wrong, and how can I fix it?
>
> #include <msp430x16x.h>
> #include <stdlib.h>
> #include <signal.h>
> #include <io.h>
>
> #define nCS_LOW { P3OUT &= ~BIT0; }
> #define nCS_HIGH { P3OUT |= BIT0; }
>
> #define WRITE_BYTE(b) { while ((IFG1 & UTXIFG1) == 1); TXBUF1 = b; }
>
> int main(void);
> void setup(void);
> unsigned char read_status_reg(void);
>
> int main(void)
> {
> setup();
> nCS_HIGH;
> while(1)
> {
> P1OUT = read_status_reg();
> }
> }
>
> unsigned char read_status_reg(void)
> {
> unsigned char x;
> nCS_LOW;
> while((IFG1 & UTXIFG1));
> TXBUF1 = 0x57; // read status reg
> x = RXBUF1;
> nCS_HIGH;
> return x;
> }
>
> void setup(void)
> {
> WDTCTL = WDTPW|WDTHOLD; // disable watchdog
>
> P1DIR = 0xFF;
> P1OUT = 0xFF;
>
> ME2 = USPIE1;
> UTCTL1 = SSEL1|SSEL0|STC;
> UCTL1 = CHAR|SYNC|MM;
> UBR01 = 0x02;
> UBR11 = 0x00;
> UMCTL1 = 0x00;
>
> P5SEL |= BIT1|BIT2|BIT3; // SPI 5.1-5.3
> P3OUT |= BIT0; // nCS output;
> }
>
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
> 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
> Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
> http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
> _______________________________________________
> Mspgcc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users