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.

PIC24HJ12GP202 w/C30 strangeness

Status
Not open for further replies.

futz

Active Member
Yesterday I breadboarded up my new PIC24HJ12GP202 and wrote a quick C30 blinky program to flash LEDs on RB12-15. No problems. That worked fine.

This morning I plug it in and it's flashing away fine. I make a trivial change to the program - nothing that would cause any problem at all, compile and program. And... nothing! It's dead! WTF?

I've checked everything I can think of but can't get a flash out of it. Tried to use the PICkit2 as debugger but it gives "PK2Error0028: Unable to enter debug mode"

The simulator runs the program just fine. Exactly the same as yesterday.

Can you guys "stupid check" this code. Have I made a mistake I can't see?
Code:
#include "p24hj12gp202.h"

_FOSCSEL(FNOSC_FRC)					//osc
_FWDT(FWDTEN_OFF)

void delay(void);

int main(void)
{
	TRISB = 0x0000;
	ADPCFG = 0xffff;				//all digital
	while(1)
	{
		LATBbits.LATB15=1;
		delay();
		LATBbits.LATB15=0;
		delay();
		LATBbits.LATB14=1;
		delay();
		LATBbits.LATB14=0;
		delay();
		LATBbits.LATB13=1;
		delay();
		LATBbits.LATB13=0;
		delay();
		LATBbits.LATB12=1;
		delay();
		LATBbits.LATB12=0;
		delay();
    }
}

void delay(void)
{
	int x,y;
	for(x=0;x<17;x++)
	{
		for(y=0;y<10000;y++){}
	}
}
 
Don't know the 24 series but I would guess that for some reason your oscillator isn't running.

Mike.
 
Is MCLR being held low? Rearrange into suitable order "at straws grasping".

Mike.
 
Pommie said:
Is MCLR being held low? Rearrange into suitable order "at straws grasping".
Heh :D Nope. MCLR is fine.

It programs with no complaints, but if I do a separate Verify I get this: "PK2Error0027: Failed verify (Address = 0xF80010 - Expected Value 0xFF - Value Read 0xA)"
 
Can't help with that. Just want to tell you that, if you want to set the particular bit (bits) of the register in C30, you can do it this way, underscore:
_LATB15 = 1;
instead of that long register name and bit name.
 
bananasiong said:
Can't help with that. Just want to tell you that, if you want to set the particular bit (bits) of the register in C30, you can do it this way, underscore:
_LATB15 = 1;
instead of that long register name and bit name.
Oh! Nice! Thanks bananasiong. :p

I got it into debug mode by adding the line
Code:
_FICD(BKBUG_ON & COE_ON & ICS_PGD2)
and I'm stepping thru it and LEDs are blinking correctly (had to shorten the delay a LOT :D ).

Now I switch back to Release, lengthen the delay back to where it was, recompile, reprogram and... it works fine! WTF???? What was all that about?

I took the debug mode line out and recompiled and it still works, so it wasn't that.
 
Last edited:
Glad you got it working. The 24 series seems to have some very non intuitive directives. BKBUG, FOSCSEL(FNOSC_FRC), FWDT(FWDTEN_OFF)

None of them are guessable. Makes me think Microsoft designed them.:D

Mike.
 
I'm not sure about your PIC, for pins that associated with JTAG, they're not usable if JTAG is not disabled in the configuration word.
 
Pommie said:
Glad you got it working. The 24 series seems to have some very non intuitive directives. BKBUG, FOSCSEL(FNOSC_FRC), FWDT(FWDTEN_OFF)

None of them are guessable. Makes me think Microsoft designed them.:D

Mike.
You got that right! The 30F has reasonably normal directives. Looks like the 24H stuff was designed by different people, and is cryptic as hell. Geesh, why make it so difficult?

The only reason I can think of for the strangeness I experienced this morning is maybe my VDDCORE regulator capacitor is a bit small. It's at the extreme minimum of the range they suggest in the datasheet. It's the only tantalum I had.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top