Other Parts Discussed in Thread: EK-TM4C123GXL
Tool/software: Code Composer Studio
Hello,
I had bought TF mini plus which supports only UART and well supports for Arduino. In online they have given code for communication between arduino and TF mini-plus. My question is how to acces UART[0], UART[1]..... UART[9] individual element in TIVA C series using CCS code. In workbook of Tiva it is mentioned only UARTCharPut and UARTCharGet.
>Below is the code for ARDUINO , Keeping it as reference Kindly help me, how to code for TIVA C series and TF mini plus
int dist;
int strength;
float temperature;
int check;
int i;
int uart[9];
const int HEADER=0x59;
if (Serial1.available()) { //check if serial port has data input
if(Serial1.read() == HEADER) { //assess data package frame header 0x59
uart[0]=HEADER;
if (Serial1.read() == HEADER) { //assess data package frame header 0x59
uart[1] = HEADER;
for (i = 2; i < 9; i++) { //save data in array
uart[i] = Serial1.read();
}
check = uart[0] + uart[1] + uart[2] + uart[3] + uart[4] + uart[5] + uart[6] + uart[7];
if (uart[8] == (check & 0xff)){ //verify the received data as per protocol
dist = uart[2] + uart[3] * 256; //calculate distance value
strength = uart[4] + uart[5] * 256; //calculate signal strength value
temprature = uart[6] + uart[7] *256;//calculate chip temprature
temprature = temprature/8 - 256;
Serial.print("dist = ");
Serial.print(dist); //output measure distance value of LiDAR
Serial.print('\t');
Serial.print("strength = ");
Serial.print(strength); //output
Thank you.