18F4685 PORTD lower 4 bits not working

Status
Not open for further replies.

3v0

Coop Build Coordinator
Forum Supporter
Code:
#pragma config OSC = IRCIO67, PWRT = OFF, WDT = OFF, MCLRE = ON, DEBUG = ON, LVP = OFF 
#include <p18f4685.h>
 
void main (void)
{
    TRISD=0x00;
    PORTD=0x00;   
    PORTD=0xFF; 
    while(1); // PORTD and LATD show 0xF0 in MPLAB SIM !
}

WATCH WINDOW [I](break on while(1) [/I])
   Update      Address    Symbol Name       Hex              Decimal        

                 F96     TRISE                 0x07                      7
                 F95     TRISD                 0x00                      0
                 F83     PORTD                 0xF0                    240
                 F8C     LATD                  0xF0                    240
Not sure why it did not show up in the watch but ECCP1CON is 0x00.
I must be missing something simple but can not see it.
Same results with all TRIS's set to zero.

Yesterday I was helping a friend with actual hardware
and it acted the same.

Thanks
3v0

edit:
Code:
1:                 #include <p18f4685.h>
2:                 #pragma config OSC = IRCIO67, PWRT = OFF, WDT = OFF, MCLRE = ON, DEBUG = ON, LVP = OFF //..............Fuse stup
3:                 
4:                  void main (void)
5:                 {
6:                     TRISD=0x00; // TRISE=0x00;
 000D0    6A95     CLRF 0xf95, ACCESS
7:                     PORTD=0x00;   
 000D2    6A83     CLRF 0xf83, ACCESS
8:                     PORTD=0xFF;  // PORTD and LATD show 0xF0 in MPLAB SIM !
 000D4    6883     SETF 0xf83, ACCESS
9:                     while(1);
 000D6    D7FF     BRA 0xd6
10:                }
 000D8    0012     RETURN 0
 
Last edited:
Needed
CMCON=0x07;

The datasheet has a tables of registers that effect PORTD but CMCON was not included.

3v0
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…