View previous topic :: View next topic |
Author |
Message |
mayur.k.vadukul
Joined: 07 Jul 2022 Posts: 40
|
PIC18F14K50 - Port Pin B4 outputs High All the time. |
Posted: Mon Apr 29, 2024 1:45 am |
|
|
Hi,
I have very basic code as below:-
#include <18F14K50.h>
#device ADC=10
#FUSES WDT //Watch Dog Timer
#FUSES WDT256 //Watch Dog Timer uses 1:256 Postscale
//#FUSES PLLEN
#FUSES BROWNOUT
#FUSES BORV19
//#FUSES INTRC
#FUSES MCLR
#use delay(internal=32MHz)
#use FIXED_IO( B_outputs=PIN_B6 )
//#use FAST_IO (B)
#use FIXED_IO( C_outputs=PIN_C5,PIN_C4 )
#define BATT_TEST_BUTTON PIN_A5
#define MAINS_IP PIN_B4
#define BATT_TEST_ON PIN_B6
#define BATT_OP PIN_C4
#define TEST_LED PIN_C5
In my main code, I have added below:-
port_a_pullups(0x20);
port_b_pullups(0x0);
The code compiles Ok, but Port Pin B4 outputs High all the time. The pin is pulled Low but because it outptus 5V, it can't be pulled Low. I tested it by removing the Pulled down resistor.
Also, I cannot debug with the compiler as well, as it keeps on showing me error that the oscillator settings are incorrect.
Can anyone help as to what could be the wrong? _________________ MVadukul |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Mon Apr 29, 2024 2:12 am |
|
|
Honestly, you either have a damaged chip, or a wiring fault on your board.
On the debugger, how is MCLR pulled up?. That fault can be a sign that
you have too small a resistor on this pin and the debugger can't pull it
down correctly to work.
You also cannot debug with the watchdog enabled. The compiler should
warn you about this if you are compiling to debug.
What compiler version?. What debugger?. What debugging environment?.
Please Learn to use the code buttons!... |
|
|
mayur.k.vadukul
Joined: 07 Jul 2022 Posts: 40
|
PIC18F14K50 - Port Pin B4 outputs High All the time. |
Posted: Mon Apr 29, 2024 2:23 am |
|
|
I have always compiled & debug with Watchdog and compiler whilst debugging, switches off the watchdog. I have used the compiler for so many micros and having trouble with this particular one.
MCLR is pulled up with 10K like all of other boards we have made.
I have tried disabling Watchdog by fuses as well but still the same result.
PCwHD 5.109.
ICD-U80 - 3.60. _________________ MVadukul |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Apr 29, 2024 5:01 am |
|
|
comments..
this...
#define MAINS_IP PIN_B4
has me concerned !
How have you interfaced the 'mains' to the PIC pin ? If it's not isolated,say with an optocoupler, it's very,very easy to damage the PIC !!
re: WDT. Until the code is 100% complete and running, you shouldn't have the WDT enabled. Historically WDT has been a hardware 'failsafe', when the program 'hangs', the WDT resets the PIC. Typically the WDT is set for 2X the programs 'loop'. There's no need for it during design/coding/testing stages and can cause problems. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Mon Apr 29, 2024 5:28 am |
|
|
10K is a lot smaller than recommended. Minimum recommended is 22K...
10K was the recommended value back in the ICD2 days. These were able
to drive a lower resistor.
The help for the ICD-U80 recommends 50K!. |
|
|
mayur.k.vadukul
Joined: 07 Jul 2022 Posts: 40
|
PIC18F14K50 - Port Pin B4 outputs High All the time. |
Posted: Mon Apr 29, 2024 5:29 am |
|
|
@tmtronic,
MAINS_IP is the low voltage input for the microprocessor and it does not get anything beyond 5V.
The hardware is fine as the old MPLAB Hi-Tech code for the board works correctly. I have disabled the WDT for the purposes of testing but I still cannot debug and the PIN B4 outputs 5V all the time. When I make the pin as Input it gives me 5V on the pin without anything connected. It indicates to me that somewhere internal pull up might be enabled, but I have ensured by writing below:-
port_b_pullups(0x0); _________________ MVadukul |
|
|
mayur.k.vadukul
Joined: 07 Jul 2022 Posts: 40
|
PIC18F14K50 - Port Pin B4 outputs High All the time. |
Posted: Mon Apr 29, 2024 5:32 am |
|
|
Ttelmah wrote: | 10K is a lot smaller than recommended. Minimum recommended is 22K...
10K was the recommended value back in the ICD2 days. These were able
to drive a lower resistor.
The help for the ICD-U80 recommends 50K!. |
I can change it to 22K, however we have so many other boards with 10k and they can be debugged using ICD-U80 fine. But the fundamentally, the error I get is with oscillator settings during debugging. It can program the device correctly on normal set up, but my pin B4 stays high when I have set it up as input and it is being pulled low on the board. _________________ MVadukul |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Mon Apr 29, 2024 7:36 am |
|
|
As I have already said, that has to be either a faulty chip, or an issue with
your board. Even if the output was driving high, it'd be under 5v with
a load. Take the chip out, and see what the pin is doing. |
|
|
mayur.k.vadukul
Joined: 07 Jul 2022 Posts: 40
|
PIC18F14K50 - Port Pin B4 outputs High All the time. |
Posted: Mon Apr 29, 2024 7:43 am |
|
|
Same board works well with the code which is old Hi-Tech compiler code for the hardware. That does work and I have converted the code into CCS compiler.
Then I stripped down the code to bare minimum to see the pins and I encountered this. I have about 5 boards and all of them have same issues, whereby the old code works correctly (MPLAB Hi-Tech) but the new code does not. I deducted the issue is in the software, but I do not see anything obvious as there is hardly anything to set other than port pin. _________________ MVadukul |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Mon Apr 29, 2024 7:49 am |
|
|
Show us the whole code used for test then. There is nothing in what you
post that would cause this. |
|
|
mayur.k.vadukul
Joined: 07 Jul 2022 Posts: 40
|
|
|
mayur.k.vadukul
Joined: 07 Jul 2022 Posts: 40
|
PIC18F14K50 - Port Pin B4 outputs High All the time. |
Posted: Mon Apr 29, 2024 8:32 am |
|
|
Thanks for the help.
Port Pint B4 is behaving correctly now. It seems that the Pull Down resistor is not soldered properly. i.e. intermittent, so when I pressed with multimeter, it worked so it was the bad luck that when I used the older code, it worked.
However, i still can't debug and keeps on stating oscillator issue.
The whole purpose of me debugging is, for me to know that what exact reading I get in my code for analogue input. But I can't debug. _________________ MVadukul |
|
|
mayur.k.vadukul
Joined: 07 Jul 2022 Posts: 40
|
PIC18F14K50 - Debugging with Internal Oscillator |
Posted: Mon Apr 29, 2024 9:26 am |
|
|
Still the issue is with debugging the micro with internal oscillator enabled and CCS have confirmed that they have simulated the fault but do not know the solution. This indicates that this might be down to compiler. _________________ MVadukul |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1909
|
|
Posted: Mon Apr 29, 2024 9:46 am |
|
|
Ttelmah wrote: | 10K is a lot smaller than recommended. Minimum recommended is 22K...
10K was the recommended value back in the ICD2 days. These were able
to drive a lower resistor.
The help for the ICD-U80 recommends 50K!. |
I usually specify 4.7k for the /MCLR pullup and I've never had issues with an ICD-U64 nor with the couple ICE4 units we had.
Extreme electrical noise forced me to go with such a low PU resistor years ago. I've stuck with it since. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Apr 29, 2024 10:51 am |
|
|
hmm... I recall some PICs cannot use the internal oscillator when run off the Pickit3. There's got to be a 'notice' about this somewhere.... |
|
|
|