CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC24EP512 - Pin B12 problem driving me nuts! [SOLVED]

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
benoitstjean



Joined: 30 Oct 2007
Posts: 566
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PIC24EP512 - Pin B12 problem driving me nuts! [SOLVED]
PostPosted: Sun May 05, 2024 9:35 pm     Reply with quote

Device: PIC24EP512GP806
Compiler: 5.026

Hi guys,

I have a stupid problem and it's driving me nuts. Just got my fresh batch of PCB's. I have two versions, one with an LCD display and one without. It's basically the same schematic and a very similar layout. Electrically, both appear fine and both behave the same.

On both, PIN B12 (pin 29) has a 10K pull-down resistor and that's it. There's a footprint for a switch that, when pressed, will put that pin high but I didn't solder it yet since there's a problem: eventhough that pin is being pulled-down on the MCU with the 10K resistor as confirmed with a multimeter, the MCU always see it as high.

I tested two things: PIN B12 as an interrupt-on-change along with 5 other pins PIN_D3, PIN_D2, PIN_D1, PIN_C14 and PIN_C13 that also have a pull-down.

The interrupt-on-change works on all these pins except for B12, it never triggers. In the interrupt code, I print the status of all pins and when either of them triggers, it indicates the state for all of them except for B12 which just says "B12 high" and only shows when the others trigger since that one never triggers and always appears high from the MCU's perspective.

So then, I disabled all the code and now I only have a while loop that will read PIN B12 and if high, turn-on an LED and if low, turn-off the LED. The LED is always high therefore the code always reads a '1' on B12. If I put my multimeter, again, that pin is low. To force it to change level, I shunt a wire between B12 and the 3.5V rail and I see the pin go high on my DMM then when I remove the wire, the pin goes back low. Again, electrically all is fine and I also confirmed on the layout that the trace is fine.... but the MCU always sees it high!

Then, I changed the code so that when high, it toggles the LED 500ms on 500ms off and if low, 100ms on and 100ms off. The flashing pattern I force onto the LED follows the problem in a sense that regardless if that pin is high or low as confirmed by my multimeter, it flashes the "high" pattern of 500ms on/off.


I coudln't find anywhere but is there anything particular with B12 that I am not aware of? Man this is really driving me nuts.

Thanks!

Ben


Last edited by benoitstjean on Mon May 06, 2024 7:15 am; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Mon May 06, 2024 2:01 am     Reply with quote

Simple answer. No.... Sad

Start with something completely different. Try driving the pin high/low
with your test code. Check that it is seen as going high/low with your
meter. Obvious thought is that the physical pin is not actually connecting
to your board. If it does not drive high/low, then you either have a fault
with the board connection, or a faulty chip.

Then moving on, some other thoughts.
This is a very old compiler. Possibly a fault with this?. Are you disabling
the parallel master port?. Are you setting up the port as not analog?.
Are you competent to look at the assembler?. If so, look and check
that the instructions to set this as not analog, and turn off the master
port are both correctly coded.
Have you tried any other way of writing to the port?. So perhaps setting
it for fast_io, explicitly setting the tris, and then manually reading
the bit of the port register. My thought here is that on your old compiler
it is possible that it has a database error with 'PIN_B12'.
I don't remember any posts around your compiler date with problems
on this pin, but doesn't mean there aren't any!...
There were issues around that time with some of the register addresses
not being correct.
benoitstjean



Joined: 30 Oct 2007
Posts: 566
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PostPosted: Mon May 06, 2024 6:19 am     Reply with quote

Thanks for your reply.

Yes, I know this is an old compiler. My new verison is on my other laptop at work.

Definitely, it has to do with PORT B configuration because I tried driving pin B14 which is not tied to anything and even if I make it go high-low in a loop with a 1 second delay between states, nothing happens... same with B12. However, I do have an LED with a transistor on B2 and that works just fine.

Mechanically, PIN B12 is connected because there's continuity between that pin and where the switch goes.

As for the parallel master port, analog etc, I don't set anything as this is the most basic code. New project, blink LED.

I wanted to get the tris state but value = get_tris_B(); as indicated in the manual which says "all devices" says that the function does not exist.

Never did any PIC assembly code so that's a no-go for me.

I'll check what I have on port B and force it to the proper setup using set_tris_b as I do have some pins as outputs and some as inputs. I looked on older circuits and I've never been anywhere higher than B10.
benoitstjean



Joined: 30 Oct 2007
Posts: 566
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PostPosted: Mon May 06, 2024 6:47 am     Reply with quote

Found it! I've been using the same design for YEARS and never got to the point of using port B pins higher than B10 as I indicated in my last message....

I was the one who drew the design for the MCU in my CAD program and I guess I inadvertedly inversed B12 and B14 and all these years, never realized that it was wrong.

I found the problem when I ran the code to output a 1Hz on/off pattern on B14 and when I put my multimeter on the switch footprint which I thought was tied to B12, the signal was there so I looked at the datasheet and that's when I saw that I had reversed the pins.

So now it works!

Thanks!

Ben
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Mon May 06, 2024 7:37 am     Reply with quote

Proves the old thing, that it is always worth 'going simple', and just toggling
pins. Very Happy
Did some checking, and there is a problem with your compiler and PortF,
it does not seem to clear the ANSEL register for this, so you may find
it is worth doing this manually. Most of the other stuff seems to work.

Glad you have solved it.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group