Hello everyone,
I'm using
TIVA-C (TM4C123G) Launchpad,
Code Composer Studio Version: 6.1.1.00022
Hercules terminal)
I was trying to get interrupt TX and RX. After that, I want to
For example when terminal sends to me a data like this ''10 20 30 40'' , I want to reply ''50''.
Firstly I am trying to when terminal sends to me '1' , my code replies ' 2 '.
But, here a problem, I am not see anything on terminal window without 'Enter Text'.
Here's my code,
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
// Used by UART interrupt handlers
unsigned char ptr[10]; // Array for storing incoming UART characters
unsigned char ReceiveData; // Incoming UART character
unsigned long i=0; // UART character pointer.
void UARTIntHandler(void)
{
uint32_t ui32Status;
ui32Status = UARTIntStatus(UART0_BASE, true); //get interrupt status
UARTIntClear(UART0_BASE, ui32Status); //clear the asserted interrupts
while(UARTCharsAvail(UART0_BASE)) //loop while there are chars
{
// Grab a character
ReceiveData = (unsigned char) UARTCharGetNonBlocking(UART0_BASE);
// Hold it
// ptr[i] = ReceiveData;
if (ReceiveData=='1') UARTCharPutNonBlocking(UART0_BASE,'2');
UARTCharPut(UART0_BASE, '2');
// Proceed to next character
// i++;
//// hold and send data
//UARTCharPutNonBlocking(UART0_BASE, UARTCharGetNonBlocking(UART0_BASE)); //echo character
}
}
int main(void) {
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
IntMasterEnable(); //enable processor interrupts
IntEnable(INT_UART0); //enable the UART interrupt
UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_TX); //only enable RX and TX interrupts
UARTCharPut(UART0_BASE, 'E');
UARTCharPut(UART0_BASE, 'n');
UARTCharPut(UART0_BASE, 't');
UARTCharPut(UART0_BASE, 'e');
UARTCharPut(UART0_BASE, 'r');
UARTCharPut(UART0_BASE, ' ');
UARTCharPut(UART0_BASE, 'T');
UARTCharPut(UART0_BASE, 'e');
UARTCharPut(UART0_BASE, 'x');
UARTCharPut(UART0_BASE, 't');
UARTCharPut(UART0_BASE, ':');
UARTCharPut(UART0_BASE, ' ');
while (1)
{
//if (ReceiveData=='1'){ UARTCharPutNonBlocking(UART0_BASE,'2'); UARTCharPut(UART0_BASE, '2');}
}