View previous topic :: View next topic |
Author |
Message |
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
SOLVED: PIC18F47K40 strange behaviour |
Posted: Mon Jun 17, 2024 3:29 am |
|
|
Good day all
I am stumped by this PIC.
I have a LED on PIN A5 with 470R. With the following code the LED flash at a 1.8Hz rate irrespective of the delay value.
This board has been in production for 2 years now with code working and now with new batch of PIC's from Mouser I get this. It is doing it on all boards with this PIC now, where as the an older batch works perfect
CCS linux Version 5.116
Code: | #include <18F47K40.h>
#include <stdint.h>
#device ADC=8
#case
#FUSES NOEXTOSC //External Oscillator not enabled
//#FUSES NOCKS //Clock Switching Disabled
//#FUSES NOFCMEN //Fail-safe clock monitor disabled
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES PUT //Power Up Timer
#FUSES LPBOR //Low-Power Brownout reset is enabled
#FUSES BORV27 //Brownout reset at 2.7V
//#FUSES WRT //Program Memory Write Protected
#FUSES NOSCANE //Scanner module is not available for use
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOPROTECT //Code protected from reads
//#FUSES EBTR //Memory protected from table reads
#FUSES NOCLKOUT
#FUSES NOWDT
#use delay(internal=64MHz)
void main(void) {
output_high(LED);
while (TRUE) {
}
}
|
When observing with a scope it looks like the port goes high Z with a 50% duty.
Anybody got an idea why.
Regards
Alan
Last edited by alan on Mon Jun 17, 2024 10:55 am; edited 1 time in total |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19495
|
|
Posted: Mon Jun 17, 2024 7:07 am |
|
|
Are you saying that the code as posted, runs correctly (so the output
goes high and stays high), on the older chips in the same board?.
If so, then really you have your answer already. Something is wrong with
these new chips....
If however the board has changed, then you should look at things like
the supply, verify the LED resistor value, and decoupling round the chip.
The time is very close to the 2 second watchdog value. Read a chip back,
and verify it's fuses have programmed correctly. |
|
|
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
|
Posted: Mon Jun 17, 2024 8:15 am |
|
|
No change on board.
Verify 100%
Nice, got 200 of these chips. However I think if it were chips I would probably have pick up something on the Microchip forums by this time
Everything seems to be running correct except pin A5. |
|
|
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
|
Posted: Mon Jun 17, 2024 8:51 am |
|
|
Just verified, not a chip restarting added the following code
Code: | while (TRUE) {
output_toggle(PIN_A7);
delay_ms(1); |
And measure 500Hz Signal on A7, tried D4 as well, also 500Hz signal.
Problem only relates to A5 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19495
|
|
Posted: Mon Jun 17, 2024 9:57 am |
|
|
On your working tests, have you got the LED connected to these other pins?.
Point is my thinking is that if there was a poor supply connection, the
chip resets when it tries to turn on the LED.....
Or might be something silly like a hidden short in the board.
Given that by default pins always wake as inputs, short A5 to A4, and try
then toggling A4.
Can you read the chip ID with your programmer. ID on the new and the older
chips?. |
|
|
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
|
Posted: Mon Jun 17, 2024 9:59 am |
|
|
I am pulling my hair out now. Supplier gave my flashing LED's |
|
|
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
|
Posted: Mon Jun 17, 2024 10:00 am |
|
|
Ttelmah wrote: |
Or might be something silly like a hidden short in the board.
|
Something silly after a day wasted |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19495
|
|
Posted: Mon Jun 17, 2024 10:20 am |
|
|
Have an official scream...... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Mon Jun 17, 2024 2:23 pm |
|
|
WOW, That's kinda funny, really....
sorry, but.....
It's NOT what ANYONE would have expected !!
Hopefully your supplier will send you the CORRECT LEDs for free. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Tue Jun 18, 2024 1:49 pm |
|
|
OK, it feels like 40*C (REAL HOT and HUMID ) here, so I've been googling...
Amazon.ca have a SINGLE LM3909 for sale for $14 CDN !!! + 13% taxes of course.
Other 'dinosaurs' will remember that chip..it's an LED flasher.ultra low power...
Got me wondering which PIC could replace it ? Probably for a lot less than just the taxes too !!!
Now trying to think IF I have any of the flashing LEDs in the parts bins... |
|
|
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
|
Posted: Wed Jun 19, 2024 5:21 am |
|
|
I can with all confidence say, I DO have flashing LED's in my bin |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19495
|
|
Posted: Wed Jun 19, 2024 6:25 am |
|
|
I can confidently say I have flashing LED's, including things like multi-
coloured ones in my opto bits drawers. My 'bits bins' occupy about 10 feet
of wall space, probably over a hundred draws and bins.
PIC10F202. Less than a dollar. |
|
|
|