Hi I am doing a project where the converted ADC will be send to UARTBufferFlag where it checks the status of data received and it will be sent out to PuTTY for testing. But I do not know how to convert from binary to ASCII or hex format, help please?
This is my main.c
-----------------------
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/adc.h"
#include "driverlib/uart.h"
#include "driverlib/interrupt.h"
#include "utils/ustdlib.h"
#include "driverlib/timer.h"
#include "UART.h"
#include "ADC.h"
#include "Timer.h"
void delay(int count){
int i, j;
for (i=0;i<count;i++)
{ for (j=0;j<1000;j++);}
}
void UARTIntHandler(void)
{
uint32_t ui32Status;
ui32Status = UARTIntStatus(UART1_BASE, true); //get interrupt status
UARTIntClear(UART1_BASE, ui32Status); //clear the asserted interrupts
while(UARTCharsAvail(UART1_BASE)) //loop while there are chars
{
UARTCharPutNonBlocking(UART1_BASE, UARTCharGetNonBlocking(UART1_BASE)); //echo character
SysCtlDelay(SysCtlClockGet() / (1000 * 3)); //delay ~1 msec
}
}
int UARTBufferFlag = 0;
int main(void) {
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
Timer_Init();
Timer0IntHandler();
ADC_Init();
UART_Init();
while (1)
{
if (UARTBufferFlag){
send_uart();
UARTBufferFlag= 0;
}
delay(100);
}
}
------------------------------- // end
This is my UART.c
------------------------
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "inc/hw_ints.h"
#include "driverlib/interrupt.h"
#include "UART.h"
#include "ADC.h"
void UART_Init (void) // initialization of UART
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinConfigure(GPIO_PB0_U1RX);
GPIOPinConfigure(GPIO_PB1_U1TX);
GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
}
void send_uart (void)
{
UARTCharPut(UART1_BASE, ui32ADC0Avg);
UARTCharPut(UART1_BASE, ui32ADC0Avg);
UARTCharPut(UART1_BASE, ui32ADC0Avg);
UARTCharPut(UART1_BASE, ui32ADC0Avg);
}
--------------------------------------------------------------- //end
