Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Intermittent working PICs

Status
Not open for further replies.
hi C,
Downloaded your [AAC] Conversation Basic Program.
Set Define to RUN in Oshonsoft IDE, also added BREAK and PORTA.2 [ manual input] to simulate a Match state.
Look at this image and add the two lines marked TEST ONLY [ don't forget Define SIMULATION_WAITMS_VALUE = 1]
Run the program, then using the hardware UART enter A123E090 for example into the UART Send window.
The program will Run to the BREAK, click PORTA.2 High on the PIC view image.
This will simulate a Match, then on the Sim Rate click Ultimate and the program will Run again.

Note the of the possible 32 STACK depth locations the Stack never goes over location 4, so the STRVEN is not a problem.
E

Hi Eric,
Works as you suggest. (After a bit of mental juggling:confused:)
Ok, regarding STRVEN, I could see that in the sim.
Does this help to tell us why the PICs aren't working?

Camerart.
 
Eric.. The STRVEN bit was just an question, I have tested C's non working chips , they don't appear to have port failures as he suspected and read / write both with and without LVP bit and no problems . However the config (h'80) is incorrect for the CONFIG3H 300005h , there are 5 config bits listed , MCLRE is one the others control mux signals to other pins., MC for some reason have not implemented ANY of these bits for the PIC18F2431 and this config should be set to 1 , ie h'9D , MPLAB 8.4 wont let me set it to anything else !.
G
 
Hi,

I changed
'Define CONFIG3H = 0x80
Define CONFIG3H = 0x9d
Same result: The good one works and the other's don't.
Camerart.
 
Bum.... ( scratches head ) , just in case is LVP set to disabled in config bit and programmer strap matches ??
 
Ok, regarding STRVEN, I could see that in the sim.
hi C,
Your conversation was Titled as STRVEN problem, so I answered accordingly.
E
 
The PICs are using Internal oscillator. As mentioned there is a LED flash at the beginning of the program, also a TOGGLE LED in the program LOOP.

All Leds flash at the beginning, only one accepts an input which runs ok and the TOGGLE LOOP LED flashes.

Is there any possibility, that the oscillator could stop after a successful start, for any reason. I was considering adding a XTL, but I may be just going up a complicated blind alley.

Camerart.
 
hi C,
I see in your program the toggle led is just after the get_count: .?
Which means the POSCNT and AZIMVAL counts are never matching, this could be due to a number of things.

I would suggest that you add an HSEROUT just after the Toggle and output the POSCNT and AZIMUTH values.

eg: Hserout "P=",#poscnt, " A=", #azimval, crlf

Post the values that you see when the PIC locks up.

Also note there is a remmed out ''Hserout "Ix=", #azimval, " ", #poscnt, CrLf in the High ISR, that should output those values when a MATCH occurs, you unrem that and see if you ever get a MATCH.

Lets know.
Eric
 
My guess. EMI issues.

If running from laptop with charger. CM noise can be significant on peripheral cables
Usually a large CM ferrite choke is needed or ground laptop via external LCD or by wire at VGA port or remove charger when needed.

just a hunch
 
hi C,
I see in your program the toggle led is just after the get_count: .?
Which means the POSCNT and AZIMVAL counts are never matching, this could be due to a number of things.

I would suggest that you add an HSEROUT just after the Toggle and output the POSCNT and AZIMUTH values.

eg: Hserout "P=",#poscnt, " A=", #azimval, crlf

Post the values that you see when the PIC locks up.

Also note there is a remmed out ''Hserout "Ix=", #azimval, " ", #poscnt, CrLf in the High ISR, that should output those values when a MATCH occurs, you unrem that and see if you ever get a MATCH.

Lets know.
Eric

Tony, I think the PICs are programming ok????

Eric,

Yes, LED Toggle after get_count Good PIC toggles Bad PICs don't

Carried out the [Hserout "P=",#poscnt, " A=", #azimval, crlf ] TEST.
Similar results. Bad PIC See screenshot 'Bad PIC', no motor turn. Good PIC starts with AxxxExxx TEST then counts up the the final number see screenshot 'Good PIC' And motor turns.

I have nearly finished a second TEST circuit, but simpler. Perhaps best to let me test that before spending more time, for the present.
 

Attachments

  • Bad PIC.jpg
    Bad PIC.jpg
    83.3 KB · Views: 322
  • Good PIC.jpg
    Good PIC.jpg
    223.1 KB · Views: 313
hi,
Disconnect the 18F4520 PORTC.4 input from the 18F2431's , then connect PORTC.4 to +5V via 1K, re-run the test.

E
 
Hi , On enabling the UART in my experience , the interrupt flag get set immediately , so its a good idea to flush (ie read ) at least once the RXREG to clear the BF bit and clear any errors. pretty much guaranteed if you have a floating input on RX pin . So the 18F4520 will need to be running ie TX at 5v before the 18F2431 is initialized. This can be done with a signal from the 4520 controlling the reset of the 2431 .
 
hi C,
That's a bummer.:(
Problem is I have dismantled my 18F4520/18F2431 quadrature project set up while I am working on nrf21 transceivers.

Looking at your latest posted program you have made a number of changes to my original test program.?
Did the original demo/test program work 'reasonably' well with your hardware.?
If yes, back track on the changes you have made.
Eric
 
hi C,
That's a bummer.:(
Problem is I have dismantled my 18F4520/18F2431 quadrature project set up while I am working on nrf21 transceivers.

Looking at your latest posted program you have made a number of changes to my original test program.?
Did the original demo/test program work 'reasonably' well with your hardware.?
If yes, back track on the changes you have made.
Eric

Hi E,

The only ideas I've got are 'my circuit' and 'RX input signals' I made a couple of test circuits, on Veroboard, that if connected together would make a complete circuit for one motor. I've programmed an 18F4520 that only sends AxxxExxx from it's TX to check the 18F2431 RX. This all works with one PIC, that has had different programs on it, since this problem arrived. Now it has the latest and it works all of the time. The puzzle is how is it different from all of the other PICs?

I try to be very careful, when altering your programs, which I had to change between test circuits, i,e, LED position, also from suggestions for 'this problem', i,e, 'LVP', but nothing serious. As far as I can recall, everything was working ok, before I made a slip up in Oshonsoft which scrambled when I opened it in Oshonsoft.

I previously asked a question that wasn't answered: If a PIC initialises, (LED flash) can the clock stall making it stop running?

I'll carry on connecting the 'new' circuit and see what that shows.

C
 
Hi,
I have been running your program in simulation, it looks OK.
Regarding the PIC init and LED flash.?
I know that you have a scope, I would suggest on the suspect PIC that you toggle more TEST output pins in the subroutines in your program, check for any that are switching when the PIC hangs up.
This should help in localising the problem, its possible that your program is stuck in a subroutine loop.
E
 
Hi,
I have been running your program in simulation, it looks OK.
Regarding the PIC init and LED flash.?
I know that you have a scope, I would suggest on the suspect PIC that you toggle more TEST output pins in the subroutines in your program, check for any that are switching when the PIC hangs up.
This should help in localising the problem, its possible that your program is stuck in a subroutine loop.
E

Hi E,

Good idea.

Camerart.
 
Is your clock fast enough to service the RX data into UART Internal 8Mhz, is not the instruction cycle , is PIC18 / 4 or 2 ?
 
Looking at the QEI_..... .asm file it looks like the RX for the AxxxExxx data is a loop in a bigger loop the RCREG is polled to see if it contains the first 'A' then waits for the next bytes if not 'A' it just reverts to main loop, I would be better if UART RX had an ISR also there does not seem to be any UART error checking ?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top