Jump to content

qwert

Members
  • Content Count

    6
  • Joined

  • Last visited

  1. qwert

    MSP 430 Launchpad Timer UART

    HEY NJC, i am using the following code now for only reception and the results are: if i check a signal on the transmission line, it gives me a signal (toggle led) on the board. but if i try to identify the character, it is not helping me do that or it is not giving any signal. Can you tell me what is the wrong that i am doing and how should i get it corrected. here is the code: #include "msp430g2231.h" #define RXD BIT2 // TXD on P1.1 #define Bitime 104 //9600 Baud, SMCLK=1MHz (1MHz/9600)=104 #define Bitime_5 0x05*4 unsigned char BitCnt; // Bit count, used when transmitting byte unsigned int RXByte; // Value sent over UART when Transmit() is called // Function Definitions void Receive(void); void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT BCSCTL1 = CALBC1_1MHZ; // Set range,,,,,,,,, DCOCTL = CALDCO_1MHZ; // SMCLK = DCO = 1MHz P1SEL |= RXD; // P1DIR |= RXD; // __bis_SR_register(GIE); // interrupts enabled while(1) { unsigned int a = RXByte; Receive(); if(a == 0x80) {P1DIR = 0x40; P1OUT ^= 0x40; } if(P1IN & 0X04) {} else {P1DIR = 0x01; P1OUT ^= 0x01; }}} void Receive() { BitCnt = 0x8; // Load Bit counter CCTL0 = SCS + OUTMOD0 + CM1 + CAP + CCIE; // Sync, Neg Edge, Cap } #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A (void) { CCR0 += Bitime; // Add Offset to CCR0 if( CCTL0 & CAP ) // Capture mode = start bit edge { CCTL0 &= ~ CAP; // Switch from capture to compare mode CCR0 += Bitime_5; } else { RXByte = RXByte >> 1; if (CCTL0 & SCCI) // Get bit waiting in receive latch { RXByte |= 0x80; BitCnt --; // All bits RXed? }}} regards qwert
  2. qwert

    MSP 430 Launchpad Timer UART

    hey , i am waiting for some suggestions..... regards QWERT
  3. qwert

    MSP 430 Launchpad Timer UART

    plazma, i want to do a different task of producing morse code corresponding to each character when it is transferred from keyboard to microcontroller..... so this is the basic concern, and character is not getting transferred to the microcontroller. this is the basic problem i am facing... what say ?
  4. qwert

    MSP 430 Launchpad Timer UART

    now, to answer some of my friends..... Yes i am being very much successful in transmitting a character from launch pad to PC , even using interrupts ..... but in this case i want to get an input from keyboard to launchpad and retransmit that character from launchpad to make it display on screen using realterm or putty, what so ever. so now , NJC, bluehash and my other friends kindly help me out doing this. regards QWERT
  5. qwert

    MSP 430 Launchpad Timer UART

    hey everyone, so i have created a new topic so as to get my problem solved. here first of all i am writing down my previous post..... here it is: hey bluehash and NJC, this is the same person that commented on your post on your forum QWERT. hey i am posting my code here.... kindly all do have a look and let me know the changes that i can made for reception and transmission using software UART (timer). hey, i want to echo a character on the screen after inputting it from the keboard, thereafter i wanna use it to generate a morse code for the characters using a piezo electric buzzer. i am quite done with the morse code part , only thing that is screwing me up is this reception so as to make different operations on individual characters .kindly help me.... here is the code : #include "msp430g2231.h" #define TXD BIT1 // TXD on P1.1 #define RXD BIT2 // RXD on P1.2 // Conditions for 9600/4=2400 Baud SW UART, SMCLK = 1MHz #define Bitime_5 0x05*4 // ~ 0.5 bit length + small adjustment #define Bitime 13*4//0x0D unsigned int RXTXData; unsigned char BitCnt; void TX_Byte (void); void RX_Ready (void); void InitializeClocks(void); void main (void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer CCTL0 = OUT; // TXD Idle as Mark TACTL = TASSEL_2 + MC_2 + ID_3; // SMCLK/8, continuous mode// ACLK, continuous mode P1SEL = TXD + RXD; // P1DIR = TXD; __enable_interrupt(); // InitializeClocks(); // Mainloop while (1) { // InitializeClocks(); RX_Ready(); // UART ready to RX one Byte _BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/ interr until char RXed // RXTXData = (unsigned char)(75); TX_Byte(); // TX Back RXed Byte Received } } // Function Transmits Character from RXTXData Buffer void TX_Byte (void) { BitCnt = 0xA; // Load Bit counter, 8data + ST/SP while (CCR0 != TAR) // Prevent async capture CCR0 = TAR; // Current state of TA counter CCR0 += Bitime; // Some time till first bit RXTXData |= 0x100; // Add mark stop bit to RXTXData RXTXData = RXTXData << 1; // Add space start bit CCTL0 = CCIS0 + OUTMOD0 + CCIE; // TXD = mark = idle while ( CCTL0 & CCIE ); // Wait for TX completion } // Function Readies UART to Receive Character into RXTXData Buffer void RX_Ready (void) { BitCnt = 0x8; // Load Bit counter CCTL0 = SCS + OUTMOD0 + CM1 + CAP + CCIE; // Sync, Neg Edge, Cap } // Timer A0 interrupt service routine #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A (void) { CCR0 += Bitime; // Add Offset to CCR0 // TX if (CCTL0 & CCIS0) // TX on CCI0B? { if ( BitCnt == 0) CCTL0 &= ~ CCIE; // All bits TXed, disable interrupt else { CCTL0 |= OUTMOD2; // TX Space if (RXTXData & 0x01) CCTL0 &= ~ OUTMOD2; // TX Mark RXTXData = RXTXData >> 1; BitCnt --; } } // RX else { if( CCTL0 & CAP ) // Capture mode = start bit edge { CCTL0 &= ~ CAP; // Switch from capture to compare mode CCR0 += Bitime_5; } else { RXTXData = RXTXData >> 1; if (CCTL0 & SCCI) // Get bit waiting in receive latch RXTXData |= 0x80; BitCnt --; // All bits RXed? if ( BitCnt == 0) { CCTL0 &= ~ CCIE; // All bits RXed, disable interrupt _BIC_SR_IRQ(LPM3_bits); // Clear LPM3 bits from 0(SR) } } } } void InitializeClocks(void) { BCSCTL1 = CALBC1_1MHZ; // Set range DCOCTL = CALDCO_1MHZ; BCSCTL2 &= ~(DIVS_3); // SMCLK = DCO / 8 = 1MHz } waiting for a positive response.... regards qwert
  6. qwert

    Anyone received their Launchpad?

    hey bluehash and NJC, this is the same person that commented on your post on your forum QWERT. hey i am posting my code here.... kindly all do have a look and let me know the changes that i can made for reception and transmission using software UART (timer). hey, i want to echo a character on the screen after inputting it from the keboard, thereafter i wanna use it to generate a morse code for the characters using a piezo electric buzzer. i am quite done with the morse code part , only thing that is screwing me up is this reception so as to make different operations on individual characters .kindly help me.... here is the code : #include "msp430g2231.h" #define TXD BIT1 // TXD on P1.1 #define RXD BIT2 // RXD on P1.2 // Conditions for 9600/4=2400 Baud SW UART, SMCLK = 1MHz #define Bitime_5 0x05*4 // ~ 0.5 bit length + small adjustment #define Bitime 13*4//0x0D unsigned int RXTXData; unsigned char BitCnt; void TX_Byte (void); void RX_Ready (void); void InitializeClocks(void); void main (void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer CCTL0 = OUT; // TXD Idle as Mark TACTL = TASSEL_2 + MC_2 + ID_3; // SMCLK/8, continuous mode// ACLK, continuous mode P1SEL = TXD + RXD; // P1DIR = TXD; __enable_interrupt(); // InitializeClocks(); // Mainloop while (1) { // InitializeClocks(); RX_Ready(); // UART ready to RX one Byte _BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/ interr until char RXed // RXTXData = (unsigned char)(75); TX_Byte(); // TX Back RXed Byte Received } } // Function Transmits Character from RXTXData Buffer void TX_Byte (void) { BitCnt = 0xA; // Load Bit counter, 8data + ST/SP while (CCR0 != TAR) // Prevent async capture CCR0 = TAR; // Current state of TA counter CCR0 += Bitime; // Some time till first bit RXTXData |= 0x100; // Add mark stop bit to RXTXData RXTXData = RXTXData << 1; // Add space start bit CCTL0 = CCIS0 + OUTMOD0 + CCIE; // TXD = mark = idle while ( CCTL0 & CCIE ); // Wait for TX completion } // Function Readies UART to Receive Character into RXTXData Buffer void RX_Ready (void) { BitCnt = 0x8; // Load Bit counter CCTL0 = SCS + OUTMOD0 + CM1 + CAP + CCIE; // Sync, Neg Edge, Cap } // Timer A0 interrupt service routine #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A (void) { CCR0 += Bitime; // Add Offset to CCR0 // TX if (CCTL0 & CCIS0) // TX on CCI0B? { if ( BitCnt == 0) CCTL0 &= ~ CCIE; // All bits TXed, disable interrupt else { CCTL0 |= OUTMOD2; // TX Space if (RXTXData & 0x01) CCTL0 &= ~ OUTMOD2; // TX Mark RXTXData = RXTXData >> 1; BitCnt --; } } // RX else { if( CCTL0 & CAP ) // Capture mode = start bit edge { CCTL0 &= ~ CAP; // Switch from capture to compare mode CCR0 += Bitime_5; } else { RXTXData = RXTXData >> 1; if (CCTL0 & SCCI) // Get bit waiting in receive latch RXTXData |= 0x80; BitCnt --; // All bits RXed? if ( BitCnt == 0) { CCTL0 &= ~ CCIE; // All bits RXed, disable interrupt _BIC_SR_IRQ(LPM3_bits); // Clear LPM3 bits from 0(SR) } } } } void InitializeClocks(void) { BCSCTL1 = CALBC1_1MHZ; // Set range DCOCTL = CALDCO_1MHZ; BCSCTL2 &= ~(DIVS_3); // SMCLK = DCO / 8 = 1MHz } waiting for a positive response.... regards qwert
×