MPLAB SIM Debugger A/D error

Status
Not open for further replies.

smart1557

New Member
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


}
 
May sound stupid but did you click APPLY in the stimulus window after selecting the .txt file ?

I am using Pin/Register Actions. Never tried what you are doing.
 
Yes, I click the apply and save. Actually I need to sample two sine wave in reality. So Can I use the pin/Register actions? Can you give me some description how to use this one? Thank you~
 
I solved this problem. But I still can not see any change in ADRESL and ADRESH when I run the program. I have no idea how to fix this problem. Can anyone give me some suggestions? which part should I focus on to fix this???Thank you very much~
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…