Ciao a tutti,
Vorrei inviare una stringa del tipo hello world (ez430-rf2500),
è il primo programma che faccio, ho copiato qualcosa sugli esempi
del CCS e su internet e quando vado a compilare ottengo tanti errori.
Potreste aiutarmi nella correzione ?
Code:
// AP invio di una stringa a 9600 baud
#include "msp430x22x4.h"
const char str[] = { "Hello World\r\n" };
unsigned int i;
int main(void)
{
// Watchdog
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
// Pin
P1DIR = 0xFF; // All P1.x outputs
P1OUT = 0; // All P1.x reset
P2DIR = 0xFF; // All P2.x outputs
P2OUT = 0; // All P2.x reset
P3SEL = 0x10; // P3.4 = USCI_A0 TXD
P3DIR = 0xFF; // All P3.x outputs
P3OUT = 0; // All P3.x reset
P4DIR = 0xFF; // All P4.x outputs
P4OUT = 0; // All P4.x reset
// Comunicazione seriale
ME1 |= UTXE0; // Enable USART TX
UCTL0 |=CHAR; // 8 bit character
UCA0CTL0 |= SSEL0; // UCLK = ACLK
UCA0BR0 = 0x03; // 32kHz/9600 = 3.41
UCA0BR1 = 0x00; //
UMCTL0=0x4A; // Modulation;
UCCTL0 &= ~SWRST; // **Initialize USART state machine**
IE1 |= UTXIE0; // Enable USART0 TX interrupt
void sendstring(char str)
{
int i = 0;
for(i = 0; i < strlen(str); i++)
{
while (!(IFG1 & UTXIFG0)); // USART0 TX buffer ready?
TXBUF0 = str[i];
}
}
}