Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

pic18f2431.....error in displaying data on the port

Status
Not open for further replies.

fareen

Full Member level 3
Joined
Oct 31, 2010
Messages
154
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,298
Activity points
2,193
Code:
# include <xc.h>
void main (void)
{
    TRISB=0;
    while(1)
    {
        LATB=0xFF;
        LATB=0x00;
    }
}
the above code dosent show 0xff on portb instead show 0xc8..
any idea why??
 

Are you connected to a debugger, or have enabled debugging in your compiler? Bits 6+7 are the ISP connections, and bit 3 is the optional debugging pin. By coincidence(?), the binary value of 0xC8 is 0b11001000.
 

im using simulator to see the output on watch window
using MPlab with XC8 compiler

- - - Updated - - -

By coincidence, the binary value of 0xC8 is 0b11001000.
meaning????
 

The pins of PORTB on the PIC18F2431 serve several purposes, you need to ensure the port is properly configured.

Both RB7/PGD and RB6/PGC are used in In-Circuit Debugging (ICD).

RB5/PWM4/PGM is used in both Low Voltage Programming (LVP) and PWM output.

RB0/PWM0, RB1/PWM1, RB2/PWM2, RB3/PWM3 and RB4/PWM4 also can serve as PWM output.

You can disable debugging (ICD) and LVP using the Configuration Register settings as well as the default behavior of the PWM modules.


Are you verifying this behavior visually or through the use of the debugger?

Setting the PORTB pins repeatly high and then low without a significant delay, might be the source of misleading visual feedback.

Also have you properly limited current through the LEDs with a current limiting resistor?

BigDog
 

Are you verifying this behavior visually or through the use of the debugger?
using debugger.
disable debugging (ICD) and LVP using the Configuration Register settings as well as the default behavior of the PWM modules.
how exactly...not using any of those modules and according to datasheet thses pin has default function of I\O port
TRISB define the port as out put port
 

You stated you are using the debugger, which require both RB7/PGD and RB6/PGC and I believe RB5 LVP is enabled by default as well.

The Configuration Register settings can be set either in code using a compiler directive or through the IDE.

Unfortunately, I limited experience with both the X MPLAB IDE and the new XC8 Compiler.

I would suggest disabling these features and include an appropriate delay between the PORTB transitions.



BigDog
 

i found the problem
PWMCON0=0x00, need to be declared, as the ports are multiplexed.
 

Code:
# include <xc.h>
void main (void)
{
    TRISB=0;
    while(1)
    {
        LATB=0xFF;
      // add some delay here 
        LATB=0x00;
     // add some delay here 
    }
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top