Hello Charles,
Thank you. I was looking for a better example. I am trying to send ADC value (0 to 5V measurement) via UART. I am using transmit_string( ) function, but I can't transmit ADC value, this function transmits only word. Could you explaian me more how to send ADC value or show better example code?
Code I am trying to use:
#include "derivative.h"
#include "ADC.h"
#include "clocks.h"
#include "UART.h"
#include "stdio.h"
#include "stdint.h"
#include "inttypes.h"
#define PTE7 7 /* Port PTE7 output to blue LED */
#define PTH0 24 /* Port PTH0 output to red LED */
#define PTH1 25 /* Port PTH1 output to green LED */
uint32_t adcResultInMv = 0;
int main(void){
int counter = 0;
// int j;
init_clks_FEE_40MHz(); /* KEA128 8MHz xtal: core 40 MHz, bus 20MHz */
GPIOB_PDDR |= 1<<PTE7 | 1<< PTH0 | 1<<PTH1; /* Output ports to LEDs */
GPIOB_PIDR &= 1<<PTE7 | 1<< PTH0 | 1<<PTH1; /* Disable inputs (default) */
init_UART(); /* Initialize UART2 9600 baud, 1 stop, no parity no IRQ */
init_ADC(); /* Init. ADC: Single conversion, SW trigger; enable adc chans 10 & 22 */
transmit_string("Running UART example\n\r"); /* Transmit string, new line, return */
for(;;) {
convertAdcChan(10); /* Convert Channel AD10 to pot on EVB */
while(adc_complete()==0){} /* Wait for conversion complete flag */
adcResultInMv = read_adc_chx(); /* Get channel's conversion results in mv */
transmit_string( " adcResultInMv " );
counter++;
}
}
Best Regards,
Irmantas