Hi, I am using a MSP430FE427 for doing a power metering project. Im using Code Composer Essentials. Currently I have no external crystal, just the internal one. I wanted to test it for starters using two leds so i wrote delay function using for loops and toggled the two leds on and off. When led 1 is off led 2 is on etc. This was fine in debug mode when in release mode led 1 was on most of the time and led 2 was off most of the time. I rewrote the delay using a timer with the same problem. Anyone know what might be going on? Also, im trying to use SPI to interface an lcd and also an external memory. The code is at the end of this post. Im just not quite sure if im setting it up all right cause it doesnt seem to want to work. Once the write enable is set in the memory the status reg should be equal to 2 and it doesnt seem to work. Any help here? I have check CS is working and also looked at the data and clock on a cro, now im thinking it something in my code. Thanks, Tony. /* Marcos */ #define FRAM_ENABLE P1OUT &= ~(BIT3) #define FRAM_DISABLE P1OUT |= BIT3 #define WRITE_SPI(data) U0TXBUF = data; while((TXEPT & U0TCTL) == 0); #define READ_SPI(data) WRITE_SPI(0xFF); data = U0RXBUF; /* Setup the fram for use */ void fram_init(void) { /* Chip select pin */ P1OUT |= BIT3; P1DIR |= BIT3; /* Set spi pins to be out/in and special */ P1DIR |= BIT6; P1SEL |= BIT6; // MOSI P1DIR &= ~BIT7; P1SEL |= BIT7; // MISO P2DIR |= BIT1; P2SEL |= BIT1; // SCK /* Setup the spi bus */ UCTL0 |= CHAR | SYNC | MM; UTCTL0 = SSEL1 | SSEL1 | STC; URCTL0 = 0x00; UBR00 = 0x10; UBR10 = 0x00; UMCTL0 = 0x00; ME1 |= USPIE0; UCTL0 &= ~SWRST; } /* Test the fram memory - light led1 if successful */ void fram_test(void) { char r1, r2, r3; FRAM_ENABLE; WRITE_SPI(FRAM_WRITE_ENABLE); FRAM_DISABLE; sleep(1); FRAM_ENABLE; WRITE_SPI(FRAM_WRITE_ENABLE); WRITE_SPI(FRAM_WRITE_MEMORY); WRITE_SPI(0x00); WRITE_SPI(0x01); WRITE_SPI(0x10); WRITE_SPI(0x11); WRITE_SPI(0x12); FRAM_DISABLE; FRAM_ENABLE; WRITE_SPI(FRAM_READ_MEMORY); WRITE_SPI(0x00); WRITE_SPI(0x01); READ_SPI(r1); READ_SPI(r2); READ_SPI(r3); FRAM_DISABLE; } --
MSP430FE427 Flashing Led and SPI
Started by ●May 8, 2006
Reply by ●May 9, 20062006-05-09
Hi,
it seems that you have a problem with clock configuration, regarding the
leds. You should be using the DCO, do you know the frequency it is
running? Check the user's guide (Basic Clock Module chapter) to see how
to configure the DCO. Probably you can use an I/O pin to output MCLK,
check the pinout in the datasheet of your device.
Regarding the SPI, you forgot to set the SWRST bit before configuring
it. Maybe this is why it's not working.
Regards,
Adriano.
Tony Myatt wrote:
> Hi,
>
> I am using a MSP430FE427 for doing a power metering project. Im using
> Code Composer Essentials. Currently I have no external crystal, just
> the internal one.
>
> I wanted to test it for starters using two leds so i wrote delay
> function using for loops and toggled the two leds on and off. When led
> 1 is off led 2 is on etc. This was fine in debug mode when in release
> mode led 1 was on most of the time and led 2 was off most of the time.
> I rewrote the delay using a timer with the same problem. Anyone know
> what might be going on?
>
> Also, im trying to use SPI to interface an lcd and also an external
> memory. The code is at the end of this post. Im just not quite sure if
> im setting it up all right cause it doesnt seem to want to work. Once
> the write enable is set in the memory the status reg should be equal to
> 2 and it doesnt seem to work. Any help here? I have check CS is working
> and also looked at the data and clock on a cro, now im thinking it
> something in my code.
>
> Thanks,
> Tony.
>
> /* Marcos */
> #define FRAM_ENABLE P1OUT &= ~(BIT3)
> #define FRAM_DISABLE P1OUT |= BIT3
> #define WRITE_SPI(data) U0TXBUF = data; while((TXEPT & U0TCTL) == 0);
> #define READ_SPI(data) WRITE_SPI(0xFF); data = U0RXBUF;
>
> /* Setup the fram for use */
> void fram_init(void) {
> /* Chip select pin */
> P1OUT |= BIT3;
> P1DIR |= BIT3;
>
> /* Set spi pins to be out/in and special */
> P1DIR |= BIT6; P1SEL |= BIT6; // MOSI
> P1DIR &= ~BIT7; P1SEL |= BIT7; // MISO
> P2DIR |= BIT1; P2SEL |= BIT1; // SCK
>
> /* Setup the spi bus */
> UCTL0 |= CHAR | SYNC | MM;
> UTCTL0 = SSEL1 | SSEL1 | STC;
> URCTL0 = 0x00;
> UBR00 = 0x10;
> UBR10 = 0x00;
> UMCTL0 = 0x00;
> ME1 |= USPIE0;
> UCTL0 &= ~SWRST;
> }
>
> /* Test the fram memory - light led1 if successful */
> void fram_test(void) {
> char r1, r2, r3;
>
> FRAM_ENABLE;
> WRITE_SPI(FRAM_WRITE_ENABLE);
> FRAM_DISABLE;
> sleep(1);
>
> FRAM_ENABLE;
> WRITE_SPI(FRAM_WRITE_ENABLE);
> WRITE_SPI(FRAM_WRITE_MEMORY);
> WRITE_SPI(0x00);
> WRITE_SPI(0x01);
> WRITE_SPI(0x10);
> WRITE_SPI(0x11);
> WRITE_SPI(0x12);
> FRAM_DISABLE;
>
> FRAM_ENABLE;
> WRITE_SPI(FRAM_READ_MEMORY);
> WRITE_SPI(0x00);
> WRITE_SPI(0x01);
> READ_SPI(r1);
> READ_SPI(r2);
> READ_SPI(r3);
> FRAM_DISABLE;
>
> }
>