txdata(app,verb,1);
break;
case CC_SET_PC:
-
case CC_CLOCK_INIT:
case CC_WRITE_FLASH_PAGE:
case CC_MASS_ERASE_FLASH:
//CLR A
cc_debug(2, 0xE4, 0, 0);
//MOVC A, @A+DPTR;
- toret=cc_debug(1, 0x93, 0, 0);
+ toret=cc_debug(3, 0x93, 0, 0);
//INC DPTR
//cc_debug(1, 0xA3, 0, 0);
.globl jtag430_tclk_flashpulses
-.type jtag430_tclk_flashpulses,@function /* declare main as a function */
+.type jtag430_tclk_flashpulses,@function //for linking
//! At 3.68MHz, 7 to 14 cycles/loop are allowed for 257 to 475kHz
//! \file platform.h
-
unsigned char serial_rx();
void serial_tx(unsigned char);
+
+unsigned char serial1_rx();
+void serial1_tx(unsigned char);
+
void setbaud(unsigned char);
+void setbaud1(unsigned char);
+
+//! Initialize the UART
void msp430_init_uart();
+//! Initialize the DCO Clock
void msp430_init_dco();
//LED on P1.0
#define PLEDDIR P1DIR
#define PLEDPIN 0x1
-
-
return c;
}
+
+//! Receive a byte.
+unsigned char serial1_rx(){
+ char c;
+
+ while(!(IFG2&URXIFG1));//wait for a byte
+ c = RXBUF1;
+ IFG2&=~URXIFG1;
+ U1TCTL &= ~URXSE;
+
+ return c;
+}
+
+
//! Transmit a byte.
void serial_tx(unsigned char x){
while ((IFG1 & UTXIFG0) == 0); //loop until buffer is free
TXBUF0 = x;
}
+//! Transmit a byte on the second UART.
+void serial1_tx(unsigned char x){
+ while ((IFG2 & UTXIFG1) == 0); //loop until buffer is free
+ TXBUF1 = x;
+}
+
//! Set the baud rate.
void setbaud(unsigned char rate){
}
}
-void msp430_init_uart(){
+//! Set the baud rate of the second uart.
+void setbaud1(unsigned char rate){
- /* RS232 */
+ //http://mspgcc.sourceforge.net/baudrate.html
+ switch(rate){
+ case 1://9600 baud
+ UBR01=0x7F; UBR11=0x01; UMCTL1=0x5B; /* uart0 3683400Hz 9599bps */
+ break;
+ case 2://19200 baud
+ UBR01=0xBF; UBR11=0x00; UMCTL1=0xF7; /* uart0 3683400Hz 19194bps */
+ break;
+ case 3://38400 baud
+ UBR01=0x5F; UBR11=0x00; UMCTL1=0xBF; /* uart0 3683400Hz 38408bps */
+ break;
+ case 4://57600 baud
+ UBR01=0x40; UBR11=0x00; UMCTL1=0x00; /* uart0 3683400Hz 57553bps */
+ break;
+ default:
+ case 5://115200 baud
+ UBR01=0x20; UBR11=0x00; UMCTL1=0x00; /* uart0 3683400Hz 115106bps */
+ break;
+ }
+}
+
+
+void msp430_init_uart(){
P3SEL |= BIT4|BIT5; // P3.4,5 = USART0 TXD/RXD
P3DIR |= BIT4;
setbaud(0);
+ //Necessary for bit-banging, switch to hardware for performance.
ME1 &= ~USPIE0; /* USART1 SPI module disable */
ME1 |= (UTXE0 | URXE0); /* Enable USART1 TXD/RXD */