Hi guys,
I have been developing a UART library for the msp430f5529 which I am testing on my msp430f5529 launchpad.
I have written the code for the USCI_A0 module and it works perfectly. Now I transferred it to the USCI_A1 module.
Basically the code (initialisation and algorithm) is exactly the same but I changed the pinouts, ISR nector name and register names from, for example, UCA0IFG to UCA1IFG (just the number).
When I run the algorithm, the process does go into the ISR, runs properly through all the processes, yet no data can be detected on the pins.
Regarding the launchpad dev board, I connected my logic analyser with the male header's pins TXD and RXD pins next to the SBW RST and SBW TST pins; i checked with the schematic of the board that these are connected with the pins 4.4 and 4.5 on the msp respectively.
The following is the code I am using:
//This function sets the UART ports and registers int UART_initialise(char *UART_module){ P4SEL |= RXD_UCA1 + TXD_UCA1 ; // P4.5 = RXD, P4.4=TXD P4DIR |= TXD_UCA1; // set as output P4DIR &= ~RXD_UCA1; // set as input UCA1CTL1 |= UCSWRST; // **Put state machine in reset** //Set UART module UCA1CTL0 = UCMODE_0; //set UART mode UCA1CTL1 |= UCSSEL_1; // Set ACLK(XT1, 32KHz) as BRCLK UCA1BR0 = 0x03; // 32kHz/9600=3.41 (see User's Guide) UCA1BR1 = 0x00; // UCA1MCTL = UCBRS_3+UCBRF_0; // Modulation UCBRSx=3, UCBRFx=0 UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine** return 1; } //This function transmits string (char array) pointed to by data_to_send //via UART. //Transfer is ready when transfer_ready variable is asserted. int UART_transmit(char *data_to_send,char *UART_module) { UART_transmit_function_UCA1 = 1; UCA1IFG &= ~UCTXIFG; //clear flag (just in case) UART_transmit_function_ready_UCA1 = 0; //global variable; 1 is transmit is ready tx_data_cnt_UCA1 = 0; //global variable; reset counter tx_data_UCA1 = data_to_send; // copy pointer to global varible tx_data_size_UCA1 = strlen(tx_data_UCA1); //global variable, calculate size of string to send UCA1TXBUF = *(tx_data_UCA1 + tx_data_cnt_UCA1*sizeof(char)); //load UART transmit buffer UCA1IE |= UCTXIE; //Enable TX interrupt return 1; } ISR: #pragma vector = USCI_A1_VECTOR __interrupt void USCIA1RTX_ISR(void){ extern int UART_transmit_function_UCA1; extern int UART_transmit_function_ready_UCA1; extern int tx_data_cnt_UCA1; extern char *tx_data_UCA1; extern int tx_data_size_UCA1; if((UCA1IFG & UCTXIFG) != 0){ ++tx_data_cnt_UCA1; if(tx_data_cnt_UCA1 <= (tx_data_size_UCA1-1)){ UCA1TXBUF = *(tx_data_UCA1 + tx_data_cnt_UCA1*sizeof(char)); //load UART transmit buffer } else { UART_transmit_function_ready_UCA1 = 1; UCA1IE &= ~UCTXIE; // Disable USCI_A0 TX interrupt UCA1IFG &= ~UCTXIFG; //clear flag //__bic_SR_register_on_exit(CPUOFF); // Exit LPM0 } } }
I am using the XTl1 oscillator(32Khz)..
Thanks for any help, any suggestion is appreciated.
Thanks for your time.
best regards,
Eman