View previous topic :: View next topic |
Author |
Message |
adesport
Joined: 03 Apr 2008 Posts: 18 Location: France
|
MPLAB SIM - PORTB can not be stimulated due to being control |
Posted: Tue Jul 28, 2009 9:58 am |
|
|
Hi all,
I'm facing a strange issue. I try to simulate my program compiled with PICC for a 18F25K20 with MPLAB SIM with asynchronous signal on RB0.
In my program I've configured all the register to enable digital input on RB0 and put a breakpoint just before a forever loop.
Unfortunately when I'm running the program (it's in the forever loop) I'm not able to simulate I/O on RB0, I have this error:
IOPORT-W0001: Pin(s) (0x01) on PORTB can not be stimulated due to being controlled by the A/D converter
So I double checked my program since it may come from a bad PORTB digital configuration, but I can't see what's wrong, here my configuration in a watch window before the forever loop :
Code: | ANSELH= 0000 0000 //Digital input buffer of RB0 is enabled
ADCON0= 0000 0000 //ADC is disabled and consumes no operating current
TRISB= 1111 1111 //All input
WPUB= 0000 0001 //Pull up ON
INTCON2bit7 = 0
FUSES :
PortB A/D enable bit is disabled |
Everything is fine while my program runs directly on the board.
I can't figure it out!
Thanks, |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
adesport
Joined: 03 Apr 2008 Posts: 18 Location: France
|
|
Posted: Tue Jul 28, 2009 10:39 am |
|
|
you're right but MPLAB SIM forum seems to be a little bit sleepy and I guess some PICC users may have seen the same behavior... |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jul 28, 2009 10:52 am |
|
|
Post a very short test program that shows the problem. Don't include
any lines of code in it that are irrelevant to the problem (i.e., most
Wizard generated code). Test the short program to verify that it shows
the problem. The program must be compilable with errors.
Also post your MPLAB version and your compiler version. |
|
![](templates/subSilver/images/spacer.gif) |
adesport
Joined: 03 Apr 2008 Posts: 18 Location: France
|
|
Posted: Wed Jul 29, 2009 1:38 am |
|
|
Here a test code without any CCS PICC macro and MPLAB screeshots.
MBLAB v8.30.00.00
CCS C Compiler 4.0.68
Code: | #include <18f25K20.h>
#BYTE ADCON0 = 0xFC2
#BYTE ANSEL = 0xF7E
#BYTE ANSELH = 0xF7F
#BYTE OSCCON = 0xFD3
#BYTE PORTB = 0xF81
#BIT RB0 = PORTB.0
#BYTE WPUB = 0xF7C
#BYTE TRISB = 0xF93
#BYTE INTCON2 = 0xFF1
#BIT _RBPU = INTCON2.7
#BYTE TRISA = 0xF92
//NOPBADEN: PORTB A/D Enable BIT = Disabled
#fuses INTRC_IO,NOPROTECT,NOLVP,NOBROWNOUT,NOSTVREN,NOWDT,NOPBADEN
#use delay(clock=16000000)
void main(){
OSCCON = 0x74; //OSC_16MHZ|OSC_INTRC
ADCON0 = 0x00; //ADC is disable
ANSEL = 0; //Digital input buffer RA & RE enabled
ANSELH = 0; //Digital input buffer of RB0-4 is enabled
TRISA = 0x00; //All output
TRISB = 0xFF; //All input
_RBPU = 0; //Enable PORTB pull-ups
WPUB = 0x01; //Enable only RB0 pull-up
while(1);
} |
When I set RB0 high through a asynch stimulus i still get the plethy message :
Quote: | (17877123) SIM-N0001 Note: Asynchronous Stimulus Set High RB0 fired.
IOPORT-W0001: Pin(s) (0x01) on PORTB can not be stimulated due to being controlled by the A/D converter |
An other test is to write directly on PORTB in the program :
Code: | #include <18f25K20.h>
#BYTE ADCON0 = 0xFC2
#BYTE ANSEL = 0xF7E
#BYTE ANSELH = 0xF7F
#BYTE OSCCON = 0xFD3
#BYTE PORTB = 0xF81
#BIT RB0 = PORTB.0
#BYTE WPUB = 0xF7C
#BYTE TRISB = 0xF93
#BYTE INTCON2 = 0xFF1
#BIT _RBPU = INTCON2.7
#BYTE TRISA = 0xF92
//NOPBADEN: PORTB A/D Enable BIT = Disabled
#fuses INTRC_IO,NOPROTECT,NOLVP,NOBROWNOUT,NOSTVREN,NOWDT,NOPBADEN
#use delay(clock=16000000)
void main(){
OSCCON = 0x74; //OSC_16MHZ|OSC_INTRC
ADCON0 = 0x00; //ADC is disable
ANSEL = 0; //Digital input buffer RA & RE enabled
ANSELH = 0; //Digital input buffer of RB0-4 is enabled
TRISA = 0x00; //All output
TRISB = 0x00; //All output
_RBPU = 0; //Enable PORTB pull-ups
WPUB = 0x01; //Enable only RB0 pull-up
PORTB = 0x00;
PORTB = 0xFF;
while(1);
} |
When PORTB = 0xFF is execute by the simulator, a watch window tell me that PORTB = 0xE0. Only PORTB pins without analogue feature are set!
![](http://www.microchip.com/forums/upfiles.aspx/55460/B8342E25B3C14684ABFF2D131209D3D8.png) |
|
![](templates/subSilver/images/spacer.gif) |
adesport
Joined: 03 Apr 2008 Posts: 18 Location: France
|
|
Posted: Wed Jul 29, 2009 2:35 am |
|
|
MPLAB v8.33 solves the problem!
I didn't test before since the release note doesn't talk bout this bug, the only solved problem which could be related is:
Quote: | SIM-551
Some bits in PORTA, PORTB, and PORTE are always 0. Even though multiplexed peripherals are disabled for 18F44K20 and 18F45K20. |
And still, I found this in "Known Problems" section (v8.33):
Quote: | SIM-572:
Invalid message "Pin(s) (0x4000) on PORTB can not be stimulated due to being controlled by the A/D converter" generated when INT1 is mapped to certain RP (RB) pins |
Which is not the case in my test program.
So now with this upgrade everything works fine, I should have test before posting! |
|
![](templates/subSilver/images/spacer.gif) |
|