I am new to PIC18F2553 processor. When I was debugger my adc code using MPLAB SIM Debugger, I met with this problem, ADC-W0008: No stimulus file attached to ADRESL for A/D. I tried to set up the input using the stimulus. I did an actual stimulus file via “register injection”. I created the ‘adcstimulus.txt’ file which contains hex values. But after this when I run my program, I still got this:
Stimulus: Synchronous stimulus applied successfully. ADC-W0008: No stimulus file attached to ADRESL for A/D. I can not see any change in the ADRESH and ADRESL.
Could you guys please give me some advice? Thank you.
code:
#include <p18cxxx.h>
#include <adc.h>
#include <delays.h>
void main_adc(void)
{
int result0,result1;
TRISB=0; //PORTB output
TRISA=1; //PORTA input
// set up the A/D module,the ADCON registers must be set
ADCON1 = 0b00001101;//VSS,VDD ref. AN0,AN1 analog only
ADCON0 = 0x00;//clear ADCON0 to select channel 0 (AN0)
ADCON2 = 0b00110101;//ADCON2 setup: Left justified, Tacq=16Tad, Tad=16*Tosc (or Fosc/2)
ADCON0bits.ADON = 0x01;//Enable A/D module
// once the A/D module is set up and enabled, we can use it to gather data:
while(1)
{
Delay10TCYx(5); //Delay for 50TCY. Because within this delay, the holding capacitor should be disconnected from the ananlog input.
ConvertADC (); // Start an A/D conversion.
while( BusyADC()); // Wait for completion. when BusyADC is cleared, the conversion is finished.
result0 = ReadADC(); // Read result
PORTBbits.RB5=result0;// Output results on RB5
}
CloseADC(); // Disable A/D converter
// second channel set up
ADCON1 = 0b00001101;//VSS,VDD ref. AN0,AN1 analog only
ADCON0 = 0x01;//clear ADCON0 to select channel 1 (AN1)
ADCON2 = 0b00110101;//ADCON2 setup: Left justified, Tacq=16Tad, Tad=16*Tosc (or Fosc/2)
ADCON0bits.ADON = 0x01;//Enable A/D module
// once the A/D module is set up and enabled, we can use it to gather data:
while(1)
{
Delay10TCYx(5); //Delay for 50TCY. Because within this delay, the holding capacitor should be disconnected from the ananlog input.
ConvertADC (); // Start an A/D conversion.
while( BusyADC()); // Wait for completion. when BusyADC is cleared, the conversion is finished.
result1 = ReadADC(); // Read result
PORTBbits.RB1=result1;// Output results on RB1
}
CloseADC(); // Disable A/D converter
}
Stimulus: Synchronous stimulus applied successfully. ADC-W0008: No stimulus file attached to ADRESL for A/D. I can not see any change in the ADRESH and ADRESL.
Could you guys please give me some advice? Thank you.
code:
#include <p18cxxx.h>
#include <adc.h>
#include <delays.h>
void main_adc(void)
{
int result0,result1;
TRISB=0; //PORTB output
TRISA=1; //PORTA input
// set up the A/D module,the ADCON registers must be set
ADCON1 = 0b00001101;//VSS,VDD ref. AN0,AN1 analog only
ADCON0 = 0x00;//clear ADCON0 to select channel 0 (AN0)
ADCON2 = 0b00110101;//ADCON2 setup: Left justified, Tacq=16Tad, Tad=16*Tosc (or Fosc/2)
ADCON0bits.ADON = 0x01;//Enable A/D module
// once the A/D module is set up and enabled, we can use it to gather data:
while(1)
{
Delay10TCYx(5); //Delay for 50TCY. Because within this delay, the holding capacitor should be disconnected from the ananlog input.
ConvertADC (); // Start an A/D conversion.
while( BusyADC()); // Wait for completion. when BusyADC is cleared, the conversion is finished.
result0 = ReadADC(); // Read result
PORTBbits.RB5=result0;// Output results on RB5
}
CloseADC(); // Disable A/D converter
// second channel set up
ADCON1 = 0b00001101;//VSS,VDD ref. AN0,AN1 analog only
ADCON0 = 0x01;//clear ADCON0 to select channel 1 (AN1)
ADCON2 = 0b00110101;//ADCON2 setup: Left justified, Tacq=16Tad, Tad=16*Tosc (or Fosc/2)
ADCON0bits.ADON = 0x01;//Enable A/D module
// once the A/D module is set up and enabled, we can use it to gather data:
while(1)
{
Delay10TCYx(5); //Delay for 50TCY. Because within this delay, the holding capacitor should be disconnected from the ananlog input.
ConvertADC (); // Start an A/D conversion.
while( BusyADC()); // Wait for completion. when BusyADC is cleared, the conversion is finished.
result1 = ReadADC(); // Read result
PORTBbits.RB1=result1;// Output results on RB1
}
CloseADC(); // Disable A/D converter
}