Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

:: PORT C Woes When Using USART

Status
Not open for further replies.

suby786

New Member
I have wireless control over my pic using the usart of the PIC16F877A. Now thats on port c 6/7

Im using portc 0-3 as my LED outputs for something else, but i cant really access it as much as i should be able to. If i wanted to set a few leds on port B, this would be fine, if i try do the same on these 0-3 bits of port C, it wont do it. It only outputs the LAST bit assignment. i.e. if i command bsf port c , 0,1,2,3 then only led connected to 3 would be on. soo dumbbbb

I can assign more than 1 of these LEDs on at startup, BEFORE i set up the USART as it acts normally. Any1 have any ideas why i cant do simple led work on port C?

ps im only requiring a single bit change, its not like im assigning b'00000000'
 
Are you using successive BSF instructions?

Code:
bsf port c, 0
bsf port c, 1
bsf port c, 2
bsf port c, 3
 
Sounds like you are experiencing the read-modify-write problem.
Have a look at this piclist article which explains it very well:


You need to do all of your bsf commands to a "shadow" reg then write the shadow reg to port c.

As to why you only get it with the usart in use I don't know, maybe it is because the chip is using more power when the usart is on. Have you got the power decoupling capacitor as near as possible to the chip?
 
i alreayd thought about summat like that, i actually tried implementing it... made a register and set what i wanted in there, then every so often i MOVF that register to PORTC. Still not working

the decoupling caps are as close as poss... There shud b no problem with power as im running the board of the mains (thru transformer with 1A 5V reg on it)
 
It sounds like you have another problem. In these days of multifunction pins you have to make sure that the pins are configured the way you think they are. You need to do way more then set the TRIS register on some parts. Recheck everything -- then do it agian. You should be able to run your code on MPLAB to see if the outputs change the way you think they should.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top