Hi,
I'm new in this tread. This is my first programming in ADC using dspic30F6014a. Currently I'm trying to read voltage values from sensors using ADC from dspic30F6014a with 20MHz osc. These values are transmitted via UART1 and displayed on the hyper terminal. I compiled the program using CCS C ver 5.010 with no errors or warning. The problem is the voltage values are not displayed on the hyper terminal screen. The port settings in hyper terminal are as follows:
Bits per second:9600
Data bits:8
Parity: none
Stop bits: 1
Flow control: Hardware
I am expecting the 13 voltages will be displayed in 1 column and ended with C character. Can anyone assist me, what did i miss/mistakes here?
Regards
FR
I'm new in this tread. This is my first programming in ADC using dspic30F6014a. Currently I'm trying to read voltage values from sensors using ADC from dspic30F6014a with 20MHz osc. These values are transmitted via UART1 and displayed on the hyper terminal. I compiled the program using CCS C ver 5.010 with no errors or warning. The problem is the voltage values are not displayed on the hyper terminal screen. The port settings in hyper terminal are as follows:
Bits per second:9600
Data bits:8
Parity: none
Stop bits: 1
Flow control: Hardware
I am expecting the 13 voltages will be displayed in 1 column and ended with C character. Can anyone assist me, what did i miss/mistakes here?
Regards
FR
CSS:
#include <30F6014A.h>
#use delay(clock=20000000)
#use rs232(baud=9600,UART1)
void InitUSART1(void);
void InitADC12 (void);
void SendADC (void);
void main()
{
setup_adc_ports(sAN0 | sAN1 | sAN2 | sAN3 | sAN4 | sAN5 | sAN6 | sAN7 | sAN8 | sAN9 | sAN10 | sAN11 | sAN12 | sAN13 | sAN14 | sAN15, VSS_VDD);
setup_adc(ADC_CLOCK_DIV_64 | ADC_TAD_MUL_8);
const int8 channel_1[]=1,2,3,4,5,6,7,8,9,10,11,12,13;
int16 ADC_value[sizeof(channel_1)];
int16 voltage[sizeof(channel_1)];
int16 value;
//I/O ports configurations(1:input, 0:output)
set_tris_b(0xFFFF); //set port_b as analog input/ADC
while(TRUE)
{
for (value=0;value <sizeof(channel_1);value++)
{
set_adc_channel(channel_1[value]);
ADC_value[value]=read_adc();
voltage[value]=ADC_value[value]*(5000/255);
}
{
printf("%4.3w\r\n", voltage[value]);
}
printf("c\r\n");
}
}