Hi,
I am a newbie and have a EK-TM4C123GXL. I am trying to transmit 9600 samples per second from ADC, using UART channels to a Bluetooth device. I am using timer triggered interrupts for sampling. However, I still could not get UART working properly. I am using a MAX232 in order to convert from UART to RS232 and see what I receive by a Terminal. I have several problems,
RealTerm gives framing error if I choose 115200, which I think I set. It gives periodic results as expected, when I choose 57600. However, the values do not correspond to what I transmit. I checked MAX232 setup, it is functioning well. What may be causing the problem? For example, for 'A', I get C1(hex), for 'B', C0(hex).
void UART_Init(void){ SYSCTL_RCGC1_R |= SYSCTL_RCGC1_UART1; SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOC; UART1_CTL_R &= ~UART_CTL_UARTEN; UART1_IBRD_R = 43; // IBRD = int(80,000,000 / (16 * 115200)) = int(43.402778) UART1_FBRD_R = 26; // FBRD = round(0.402778 * 64) = 26 // 8 bit word length (no parity bits, one stop bit, FIFOs) UART1_LCRH_R = (UART_LCRH_WLEN_8|UART_LCRH_FEN); UART1_CTL_R |= UART_CTL_UARTEN; // enable UART GPIO_PORTC_AFSEL_R |= 0x30; GPIO_PORTC_DEN_R |= 0x30; GPIO_PORTC_PCTL_R = (GPIO_PORTC_PCTL_R&0xFF00FFFF)+0x00220000; GPIO_PORTC_AMSEL_R &= ~0x03; } unsigned char UART_InChar(void){ while((UART1_FR_R&UART_FR_RXFE) != 0); return((unsigned char)(UART1_DR_R&0xFF)); } void UART_OutChar(unsigned char data){ while((UART1_FR_R&UART_FR_TXFF) != 0); UART1_DR_R = data; } int main(void){ PLL_Init(); UART_Init(); ADC0_InitTimer0ATriggerSeq3(0, 76, 64934); while(1){ WaitForInterrupt(); UART_OutChar('f'); WaitForInterrupt(); UART_OutChar('g'); } }