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.

PIC16F722A . PORTB Bits not latching

Status
Not open for further replies.

1230

Member level 3
Member level 3
Joined
Jun 18, 2002
Messages
62
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
355
hi all...
writing a simple code to make understand the problem.
PORTB bit 4 should remain high all the time. but its going low after making change to portb. bit5.
cannot trace the problem, pls help.
int main()
{
TRISB=0X00;

PORTB |=(1<<4);
Delay_ms(2000);

while(1)
{
PORTB |=(1<<5);
}
}
 

Probably a RMW problem which is well documented. The PIC16 series doesn't simply set individual bits when you write to a port, it reads the whole port, sets the bit then writes it all back again. If bit 4 is externally floating low or pulled low, the write (OR operation) to bit 5 reads bit 4 as zero so it writes it back as zero.

The PIC18 series uses LAT registers to overcome the problem but the simple solution to your issue is to keep a variable for the bit operations and write it to PORTB whenever you change its contents.

Brian.
 
  • Like
Reactions: 1230

    1230

    Points: 2
    Helpful Answer Positive Rating
Probably a RMW problem which is well documented. The PIC16 series doesn't simply set individual bits when you write to a port, it reads the whole port, sets the bit then writes it all back again. If bit 4 is externally floating low or pulled low, the write (OR operation) to bit 5 reads bit 4 as zero so it writes it back as zero.

The PIC18 series uses LAT registers to overcome the problem but the simple solution to your issue is to keep a variable for the bit operations and write it to PORTB whenever you change its contents.

Brian.
Thanks sir...
but i found the problem.
pic16 series write an individual pins of a port. in my code, i have to disable the ANSELB registor. after disabling my problem solved
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top