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

SOLVED: PIC18F47K40 strange behaviour

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



Joined: 12 Nov 2012
Posts: 357
Location: South Africa

View user's profile Send private message

SOLVED: PIC18F47K40 strange behaviour
PostPosted: Mon Jun 17, 2024 3:29 am     Reply with quote

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: 19529

View user's profile Send private message

PostPosted: Mon Jun 17, 2024 7:07 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jun 17, 2024 8:15 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jun 17, 2024 8:51 am     Reply with quote

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: 19529

View user's profile Send private message

PostPosted: Mon Jun 17, 2024 9:57 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jun 17, 2024 9:59 am     Reply with quote

I am pulling my hair out now. Supplier gave my flashing LED's Bummed Out Bummed Out
alan



Joined: 12 Nov 2012
Posts: 357
Location: South Africa

View user's profile Send private message

PostPosted: Mon Jun 17, 2024 10:00 am     Reply with quote

Ttelmah wrote:

Or might be something silly like a hidden short in the board.


Something silly after a day wasted Very Happy
Ttelmah



Joined: 11 Mar 2010
Posts: 19529

View user's profile Send private message

PostPosted: Mon Jun 17, 2024 10:20 am     Reply with quote

Have an official scream...... Very Happy
temtronic



Joined: 01 Jul 2010
Posts: 9232
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Jun 17, 2024 2:23 pm     Reply with quote

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: 9232
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Jun 18, 2024 1:49 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jun 19, 2024 5:21 am     Reply with quote

I can with all confidence say, I DO have flashing LED's in my bin Very Happy Very Happy
Ttelmah



Joined: 11 Mar 2010
Posts: 19529

View user's profile Send private message

PostPosted: Wed Jun 19, 2024 6:25 am     Reply with quote

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. Very Happy
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