binzer
Member
I am trying to run my Junebug in Mplab Debug mode to watch adc data change and to watch the output of some equations.For some reason this seems extremely slow and I think it is because I am missing a setting somewhere. I am using MCC18. Here is the code.
I want to read some ADC channels / etc and send them out the USART, just getting the hang of reading the ADC and converting to readable data for the other end.
Tnx, Mike
Code:
// JuneBug Info
// Buttons RB0, RB2, RB5.
// Analog AN1, AN3
// IR RB0
// LED's RA0, RA6, RA7
//
// configuration
#pragma*config OSC = INTIO2, WDT = OFF, LVP = OFF, PWRT = ON, BOR = OFF
#include <stdlib.h>
#include <p18f1320.h>
#include <usart.h>
#include <adc.h>
#include <delays.h>
#include <portb.h>
unsigned char config;
unsigned int spbrg;
int reslta0;
int reslta3;
int reslts0;
int reslts3;
char A1;
char B1;
void main(void)
{
OpenUSART (USART_ASYNCH_MODE &
USART_TX_INT_OFF &
USART_RX_INT_OFF &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH,
25 );
OpenADC (ADC_FOSC_32 & ADC_RIGHT_JUST & ADC_12_TAD,
ADC_INT_OFF & ADC_VREFPLUS_VDD & ADC_VREFMINUS_VSS, 03);
while (1)
{
SetChanADC(ADC_CH1);
Delay10TCYx(5);
ConvertADC();
while( BusyADC() );
reslta0 = ReadADC();
reslts0 = (reslta0+1)*500/1024;
itoa (reslts0, A1);
SetChanADC(ADC_CH3);
Delay10TCYx(5);
ConvertADC();
while( BusyADC() );
reslta3 = ReadADC();
}
}
Tnx, Mike
Last edited: