Not happy, 2 dead 40X2 chips

bigg_al

New Member
Now that I've started bread boarding to check out my code, I've hit another roadblock, grrr.
I am using the PIC18F45K22 which should run on 2.1 to 5.5 volts.
I am using a regulated 5 volt supply.
In each case everything seemed fine. I was able to download and run a few iterations of my code.
However, after no more than an hour, I would get the "No hardware found on COM1" error.
I checked my connections and rebooted the PC with no change. Both chips appear to be dead.
I put in a 20X2 just to check my system and it works fine. (I have not run the 20X2 for extended time yet)
What gives?
Thanks, Al
 

westaust55

Moderator
Performing a hard reset as indicated by Technoman should solve the problem if your code is in a tight loop where it does not have time to check the SerIn pin for a new download.

since you mention a breadboard, how are you connecting the download circuit to the breadboard? Stereo sockets do not have pins of sufficient length to achieve good contact.

Do you have the reset pin pulled high using say a 10 kOhm resistor to the supply line?
A clear photo of your breadboard layout may help folk here to identify any physical concerns.
 

inglewoodpete

Senior Member
About the only thing that will kill a PICAXE is over-voltage (or a big hammer 😲 ). I have used well over 100 PICAXE chips and had two failures - both because I inadvertently connected voltages >5.5v onto the power supply or other pins.

I note that the download failure is being reported on COM1, which implies that your are using an RS-232 port on your computer's motherboard. These typically provide +/-12v logic levels, so it is critically important that the 22k+10k download circuit is wired correctly.

You don't mention your setup: PCB, stripboard or breadboard?

Note also that the 40X2 (PIC18F45K22) must have power, ground supplies and capacitors connected to BOTH pairs of power pins.
 
Last edited:

stan74

Senior Member
PIC18F45K22 ....is that 40x2 as 28x2 is pic18f25k22?
have you ubiquitous cap across vss and vdd
why does it have 2 v+ and gnd ?
 

bigg_al

New Member
Thank you for the replies. It took a few tries, but I was able to communicate with the chips again.
I did not have both sets of V+ and 0V hooked up. I do now.
 

erco

Senior Member
Welcome bigg_al. Sounds like you solved your Christmas issue on New Years' Day so your 2021 is already off to a good start!
 

B4Lamb

Member
Thanks Technoman and westaust55,

You saved my bacon as well. I thought id blown my second expensive 20X2 chip. It was a hardware reset I needed to do.
I'm trying to configure the internal timer to generate 50 ms Interrupts but I may not have the settings quite right yet so probably I have it set too fast and as said excluding the ability to detect the serin pin for a new program load.0
Can anyone indicate what is the shortest interrupt loop time I can set up to not lock out programming??
 

Buzby

Senior Member
What frequency are you running the 40X2 at ?.

I ran the 28X2 ( same as 40X2, but less pins ) at 64MHz and had no problem with 1mS interrupts.

As long as your interrupt routine is correctly constructed, something like this ...
Code:
' Main routine
' ---------------
  settimer Tpreval                    ' Set timer preload value  ( See page 233 of Manual 2 for how to calculate Tpreval )
  timer = 0xffff                        ' Preset to interrupt at next overflow
  toflag = 0                              ' Clear timer flag
  setintflags %10000000,%10000000             ' Interrupt on timer overflow

' Interrupt routine
' ------------------
interrupt:
:
:     interrupt actions code goes here
:
' Generate another interrupt at next overflow
   timer = 0xFFFF                              
   toflag = 0  
   setintflags %10000000,%10000000 ' Interrupt on timer overflow
return ' Return from interrupt
... then you should never 'lock up', as the firmware checks for downloads between each instruction, even during interrupts.

If you post your code we can help,

Cheers,

Buzby
 

B4Lamb

Member
Thank You Buzby,
Its a 20X2 i'm running and only at the default 8 MHz at the moment, I may increase this later when I can't fit in what I want to do.
I did miss off the setintflags in the Interrupt routine in my code but I've added that and its rattling away nicely now with 50 ms Interrupts as I wanted.
Its the base clock resolution I need for my app.
I'm importantly not locking out the ability to update the program at any time.
The other chip I thought I killed thankfully was not tossed in the bin as I'm sure now its perfectly OK
Thankyou again.

B4Lamb
 

Flenser

Senior Member
B4Lamb,

One technique that is used is to have a loop that does nothing at the start of your program, like this:
Code:
for b0 = 1 to 2000
next b0
The rest of your code can then do whatever you need it too, including having a short interrupt loop time that locks out programming .

This doesn't stop the rest of your code preventing a new download from starting but if your code is preventing a download then you can just do the hard reset process and immediately start a new download. This first thing that runs is this for loop which does not block a new download.
 

westaust55

Moderator
b0 as a byte variable cannot go greater then 255.

however, an alternative is to have a pause command such as
PAUSE 2000 ; change the value to match clock speed up to 65535 to achieve around 2 sec delay.
 

B4Lamb

Member
I generally have an Initislisation section at the beginning for setting up I/O which includes a delay loop or a generous Pause for external hardware I/O to settle down before enabling the main section of code where interrupt calls may be used. I generally like clock driven synchronous code, even though I may tend to use state machines for the general architecture. I'm definitely old school. I do really try to avoid Pause commands as a lot of stuff can be done during these periods. That is the main reason I like clock driven interrupt calls where I can have a few count down registers on the go when I need a delay or nested delays. It was a breath of fresh air when I realised the *X2 parts had the ability to trigger an interrupt from an internal timer roll over even though the response time is as instant as you get when assembly language programming.
 

B4Lamb

Member
It was a breath of fresh air when I realised the *X2 parts had the ability to trigger an interrupt from an internal timer roll over even though the response time is as instant as you get when assembly language programming.
Sorry ....not as instant as assembly language programming
 

Buzby

Senior Member
Sorry ....not as instant as assembly language programming
Nothing on a PICAXE is as fast as assembler, but PICAXE is plenty fast enough for most applications, and far easier to program.

The interrupt mechanism on PICAXE is not an interrupt from the underlying processor. It is a check performed by the firmware between each PICAXE instruction, looking to see if an interrupt condition is currently met.

However, if the interrupt condition only exists for a few uS, then the PICAXE might miss it, as it will have been and gone by the time the firmware finishes the current instruction.

In this case you can use the HINT ( hardware interrupt ), which will set the hardware interrupt flag. The firmware will detect this when it next checks, even if the cause of the interupt has already gone.

Note, the 'hardware interrupt' is not faster than a 'normal interrupt', but it can detect very short interrupt conditions which 'normal' might miss.

Also note that the interrupt latency ( time from pin-change to code execution ) varies slightly due to differing instruction timings, but if this a problem for you it's time to move to a different platform !.

Cheers,

Buzby
 

B4Lamb

Member
Yes I can certainly cope with the interrupt latency of picaxe for my current application. As you rightly point out the programming is so much easier. I.e try writing the code for reading an 18B20 single pin temperature sensor in assembler!!
I'm using a small PIC processor with code written in assembler for the really time critical stuff so the picaxe is used for the number crunching and text processing stuff.
Thank you buzby for your help.
 
Top