1
\$\begingroup\$

I have some experience with PIC micro controllers ASM. But decided to move on to C. Having installed MPLABX IDE V3.55 and with the C compiler XC8. I now try to realize a program for PIC16F877A.

After initialization I try to set some output ports but there is no reaction in the simulator. When I try to change a port setting with a stimulus there is also no reaction. Where is the mistake?`

// Set PORTA and PORTE to digital 
    ADCON1 = 0B00000111;
   // Turnoff PORTA comparitors
    CMCON  = 0B00000111;
   // Set I/O PORTE
    TRISE  = 0B00000111;
   // Set PORTB to input
    TRISB  = 0B11111111;
   // Initialize temperature routine varables.
   //  minLimit = 0;
   //  MaxLimit = cycleTime;
   // The switches SW1 - SW5 are pulled up against VDD
   // When unpressed RE2 must be high
   // Enter button SW3 open
    PORTEbits.RE2 = 0x01;`

Even in watch I can not change the value. I can change the value in SFR.

Is it possible that I run into the R-M-W cycle problem?

\$\endgroup\$
3
  • 1
    \$\begingroup\$ You've set RE2 as an input in TRISE - so trying to set PORTEbits.RE2 to some value isn't going to do much. That old PIC doesn't have separate PORTx & LATx registers for reading & writing, so you do need to be more aware of RMW, but I don't think that's your issue here... \$\endgroup\$
    – brhans
    Mar 21, 2017 at 12:43
  • \$\begingroup\$ Which simulator are you using? Proteus ISIS? \$\endgroup\$
    – C K
    Mar 21, 2017 at 15:48
  • \$\begingroup\$ I am using the simulator that comes with MPLABX. \$\endgroup\$
    – Decapod
    Mar 22, 2017 at 10:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.