Merhaba Arkadaşlar;
MSP430 ile Xbee denemesi yapmak istiyorum bunun için msp430G2553 ile yapmak istedim çünkü bundan Direk kütüphane içinde UART kısmı varmış internetten okudum.Hatta koduda paylaşıyorum birisi bana bu konuda yardımcı olabilir mi acaba?Normalde ingilizcem çok çok iyidir ama ben kodu anlamadım.Özellikle kod konusunda yardımcı olursanız sevinirim.
#include <msp430g2553.h>
////////////////Defines////////////////
#define Green_LED BIT6
#define Button BIT3
#define Error BIT0
////////////////Function Protos////////////////
void TX(char *tx_message);
////////////////Main Program////////////////
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 = CALBC1_1MHZ; // Set DCO to 1MHz
DCOCTL = CALDCO_1MHZ;
////////////////USCI setup////////////////
P1SEL = BIT1 + BIT2; // Set P1.1 to RXD and P1.2 to TXD
P1SEL2 = BIT1 + BIT2; //
UCA0CTL1 |= UCSSEL_2; // Have USCI use SMCLK AKA 1MHz main CLK
UCA0BR0 = 104; // Baud: 9600, N= CLK/Baud, N= 10^6 / 9600
UCA0BR1 = 0; // Set upper half of baud select to 0
UCA0MCTL = UCBRS_1; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST; // Start USCI
////////////////General GPIO Defines////////////////
P1DIR |= (Green_LED); //Define GPIOs as outputs else GPIOs are inputs
P1DIR &= ~(Button); //Define Button as input. Line is not necessary but is for readibility
P1OUT = 0; //All Outputs off except for Green_LED
////////////////Main Loop////////////////
while(1)
{
if( (BIT3 & P1IN)==0)
{
P1OUT ^= Green_LED; // Toggle Green LED
TX("Hello World!!!"); //Transmit Message to Terminal
TX("\r\n"); //Transmit Line Break
__delay_cycles(250000); //Software delay to add debounce
}
} // End While
} // End Main Program
////////////////Functions////////////////
void TX(char *tx_message)
{
unsigned int i=0; //Define end of string loop int
char *message; // message variable
unsigned int message_num; // define ascii int version variable
message = tx_message; // move tx_message into message
while(1)
{
if(message[i]==0) // If end of input string is reached, break loop.
{
break;
}
message_num = (int)message[i]; //Cast string char into a int variable
UCA0TXBUF = message_num; // write INT to TX buffer
i++; // increase string index
__delay_cycles(10000); //transmission delay
if(i>50) //prevent infinite transmit
{
P1OUT |= Error;
break;
}
} // End TX Main While Loop
} // End TX Function
http://connect.cizgi-tagem.org/l31548631/ (http://connect.cizgi-tagem.org/l31548631/) buradaki
dersi izlerseniz daha rahat anlayacağınızdan
eminim.
Ayrıca http://www.mcu-turkey.com/msp430-launchpad-msp430g2553-donanimsal-uart-kullanimi/ (http://www.mcu-turkey.com/msp430-launchpad-msp430g2553-donanimsal-uart-kullanimi/)
http://www.mcu-turkey.com/cc2530-mini-znp-kit-zigbee-ornek-uart-uygulamasi/ (http://www.mcu-turkey.com/cc2530-mini-znp-kit-zigbee-ornek-uart-uygulamasi/)
buraları da inceleyiniz.
Saygılar...
Not: Dersleri izleyebilmek için http://www.cizgi-tagem.org (http://www.cizgi-tagem.org)
sitesine üye olmanız gerekmekte.(Pişman olmazsınız. :P)
Bende bu mesajı yazdıktan 10 dk sonra çizgitagemde buldum ve izlemeye başlamıştım :)
sağolun yinede :D