This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

send integer through Bluetooth from TM4C123 microcontroller

i want to send Temperature sensor and Co2 sensor reading form Tm4C123 vis Bluetooth to app on the phone. I have some code here, i can display CO2 and Temperature reading on the LCD screen, but i can not send these through UART. Hoping anyone can give me some points. Thanks

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include <stdint.h>
#include "tm4c123gh6pm.h"
#include "ST7735.h"
#include "PLL.h"
#include "SysTick.h"
#include <stdbool.h>
#include "CO2_Sensor.h"
#include "Temp_Header.h"
#include "Bluetooth.h"
void EnableInterrupts(void);
void WaitForInterrupt(void);
extern uint8_t rx_data[8];
extern uint8_t rx_index;
double co2_calculation;
int main(void){
PLL_Init(); //Initilize PLL to 80MHz
SysTick_Init(); //Initilize SysTick Timer
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
this is mu Main code

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include "tm4c123gh6pm.h"
#include <stdint.h>
#include "SysTick.h"
double Bluetooth_baudCalc = 0;
double Bluetooth_fractionBaud = 0;
int Bluetooth_integerBaud = 0;
int Bluetooth_calcFractionBaud = 0;
int Bluetooth_regBits = 0;
int Bluetooth_Parity = 0;
void Bluetooth_UART_Init(int Bluetooth_bits,int Bluetooth_stopBits, char Bluetooth_parity, double Bluetooth_baudRate){ volatile uint32_t delay;
SYSCTL_RCGCUART_R = 0x80; // UART module 7 enable and activate clock
SYSCTL_RCGCGPIO_R |= 0x10; // activate clock for Port E
UART7_CTL_R = 0; // Disable UART7
GPIO_PORTE_AFSEL_R = 0x03; // set alt funct on PE0 and 1
GPIO_PORTE_PDR_R = 0x10;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
this is my Bluetooth library

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include <stdint.h>
#include "stdint.h"
#include "PLL.h"
#include "Systick.h"
#include "tm4c123gh6pm.h"
int firstByte; // Variable for first byte to be assigned.
int secByte; // Varible for second byte received.
int temp; // Variable for temp sensor data
void tempSensor_Init(void) { // Function initializes port E pin 4 and 5 I2C to transmit and recieve from sensor.
SYSCTL_RCGCGPIO_R |= 0x10; // Turns on port E clock.
SYSCTL_RCGCI2C_R |= 0x04; // turns on PWM system
GPIO_PORTE_AFSEL_R = 0x30; // Select alternate function
GPIO_PORTE_PCTL_R = 0x00330000; // Selects M0PWM6 for PE0
GPIO_PORTE_ODR_R = 0x20; // Sets pin 4 and 5 to open drain.
GPIO_PORTE_DIR_R = 0x20; // Sets PE0 as an output.
GPIO_PORTE_AMSEL_R = 0x00; // Disable analog mode.
GPIO_PORTE_DEN_R = 0x30; // Enable digital mode.
I2C2_MCR_R = 0x10; // Enable master.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
this is my temperature code

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include <stdint.h>
#include "tm4c123gh6pm.h"
#include "ST7735.h"
#include "PLL.h"
#include "SysTick.h"
#include <stdbool.h>
volatile uint8_t rx_data[8];
volatile uint8_t rx_index = 0;
double baudCalc = 0;
double fractionBaud = 0;
int integerBaud = 0;
int calcFractionBaud = 0;
int regBits = 0;
int Parity = 0;
void CO2_UART_Init(int bits,int stopBits, char parity, double baudRate){ volatile uint32_t delay;
SYSCTL_RCGCUART_R = 0x02; // UART module 1 enable and activate clock
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
this is mu CO2 sensor code

0