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

Starting PIC24HJ128GP202 [SOLVED]

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



Joined: 07 Nov 2015
Posts: 9

View user's profile Send private message

Starting PIC24HJ128GP202 [SOLVED]
PostPosted: Sat Nov 07, 2015 6:07 am     Reply with quote

Hello,

I'm trying to program the PIC24HJ128GP202 with compiler version 5.007 for a simple blinking led function to confirm if the code and MCU works. For the clock I will be using the internal clock.

The code is as following:

Code:
#include <24HJ128GP202.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES CKSFSM                              //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES PUT64                    //64ms delay when power up
#FUSES NODEBUG
#FUSES FRC
#use delay(internal=7370000)

void main()
{
      while(TRUE)
      {
            output_high(PIN_B15);
            delay_ms(500);
          output_low(PIN_B15);
          delay_ms(500);
      }
}


I program this with Pickit 2 (i know it's old but it works). But after programming I see now blinking LED only a led that stays on. I have tried different option for the clock but no improvements. And now i'm completely confused with it.

Additional information about the configuration:
MCU: | Pickit
MCLR | MCLR
VSS | Vss (GROUND)
VDD | Vdd Target
VSS | Vss (GROUND)
VCAP | With a 4.7uf ELCO to Vss (GROUND)
AVss | Vss (GROUND)
AVdd | Vdd Target

If anyone knows what the problem can be I will be a very happy person.


Last edited by ING.remco on Mon Nov 16, 2015 12:47 pm; edited 1 time in total
temtronic



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

View user's profile Send private message

PostPosted: Sat Nov 07, 2015 6:17 am     Reply with quote

have you set the 'build configuration' in MPLAB to 'release' instead of 'debug' ?

jay
ING.remco



Joined: 07 Nov 2015
Posts: 9

View user's profile Send private message

PostPosted: Sat Nov 07, 2015 7:03 am     Reply with quote

I'm write the program in CCS C compiler and program the MCU with the dedicated tool for pickit 2. So there is no MPLAB involved.
Ttelmah



Joined: 11 Mar 2010
Posts: 19484

View user's profile Send private message

PostPosted: Sat Nov 07, 2015 8:47 am     Reply with quote

You have got a current limiting resistor to the LED?.
I've seen people have this sort of behaviour where there is not a suitable resistor, and the chip overloads when the LED goes on.
Does your 'Ecap' have the low ESR required. It really wants to be a SMD cap _very_ close to the pins....
Other comment what other smoothing is present?.
Look at figure 2.1 in the data sheet. The 0.1uF ceramic capacitors are required, and should be as close as practical to the pins.
ING.remco



Joined: 07 Nov 2015
Posts: 9

View user's profile Send private message

PostPosted: Sat Nov 07, 2015 9:43 am     Reply with quote

Yup there is a current limiting resistor that does not allow any current higher than 5 mA (that's what the pin maximum can handle). Even tested it only with an oscilloscope, but that didn't help either.
And I also placed the decoupling capacitors, but it didn't helped. Theoretically it would work without the decoupling capacitor only it would not be optimum.
No other smoothing is present, but places some for a test but didn't helped either.
wangine



Joined: 07 Jul 2009
Posts: 98
Location: Curtea de Arges, Romania

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Sat Nov 07, 2015 2:41 pm     Reply with quote

Check very carefuly the AVdd and VCap/Vddcore respectively 7 and 17. I don't remember wich one needs just a capacitor, no VDD, just read datasheet about those pins. I just search now pdf. It's the Vcap/vddcore, page 15 on table 1-1. Also more is explained on page 16, 2.3 cap. I remember i put a smd ceramic cap to be very close on pins.
Here is my config, should work on most 24F family.
Code:

#include <24FJ192GA110.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WPOSTS16                 //Watch Dog Timer PostScalar 1:32768
#FUSES NOWINDIS                 //Watch Dog Timer in Window mode
#FUSES ICSP1                    //ICD uses PGC1/PGD1 pins
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOJTAG                   //JTAG disabled
#FUSES NOPR                     //Pimary oscillaotr disabled
#FUSES IOL1WAY                  //Allows only one reconfiguration of peripheral pins
#FUSES NOOSCIO                  //OSC2 is clock output
#FUSES NOCKSFSM                 //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES FRC_PLL                  //Internal Fast RC oscillator with PLL
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES WPFP                 
#FUSES NOWPDIS               
#FUSES NOWPCFG               
#FUSES WPEND_LOW
//#FUSES NOMCLR             

#use delay(clock=32000000)

#include "sincro_signal.c"

Just take a try.
ING.remco



Joined: 07 Nov 2015
Posts: 9

View user's profile Send private message

PostPosted: Sun Nov 08, 2015 1:32 pm     Reply with quote

I have rebuild the whole setup and added all the decoupling capacitor. And in addition added some capacitors on the power supply line (more than enough). Also replaced the 4.7 uF for a 10 uF (atm no low ESR possible). And included all the #fuses that wangine had provided. But still no improvements. I really don't get it anymore. Is it really that hard MCU to get running?
Eugeneo



Joined: 30 Aug 2005
Posts: 155
Location: Calgary, AB

View user's profile Send private message

PostPosted: Sun Nov 08, 2015 1:52 pm     Reply with quote

I remember having some issues with the clock speed on this pic. I know this works so hopefully it helps.

Code:


#FUSES FRC_PLL                  //Internal Fast RC oscillator with PLL

#word RCON=0x0740
#word OSCCON=0x0742
#word CLKDIV=0x0744
#word PLLFBD=0x0746
#word OSCTUN=0x0748

//              xxx frcdiv
//             x doze en
//          xxx doze
//                 xx PLL POST
//                    xxxxx PLL PRE
//CLKDIV=0B0011000000000000;
//CLKDIV=0B0011001100000000;
#define PLL_DOZE 8*4096       // 0=/1, 1=/2, 2=/4 3=/8, 4=/16, 5=/32,  6=/32, 7=/128

// ***** 80.005 Mhz tested
#define  PLL_PRE 0            // 0= input/2  1=input/3  ... 32=input/33
#define  FRC_DIV 0*256        // 0=/1, 1=/2, 2=/4 3=/8, 4=/16, 5=/32,  6=/32, 7=/256
#define  PLL_FBD 41           // 0=2,1=3,2=4, 512=513
#define PLL_POST 0*64         // 0= input/2  1=input/4  2=none 3=input/8
#define OSC_TUNE 52         // 0 - 63

#define CLOCK_DIV_VALUE PLL_PRE+PLL_POST+FRC_DIV
#define set_osc_high_speed CLKDIV=CLOCK_DIV_VALUE;PLLFBD=PLL_FBD;OSCTUN=OSC_TUNE;

set_osc_high_speed   // 80.005 Mhz


ING.remco



Joined: 07 Nov 2015
Posts: 9

View user's profile Send private message

PostPosted: Sun Nov 08, 2015 2:27 pm     Reply with quote

Thank you all for the comments. But I found the problem. It was just a F****** freshman mistake. NEVER EVER TRUST A BREADBOARD. I thought it would be easy to test it fast with a breadboard but of course that was the problem. Rebuild on something different and it WORKS. Afterhand I also tested if the decoupling capacitors were needed. But after removing them all the setup still functioned. And the capacitor for the Vcap could also be a normal Elco with no special ESR rating. So about that was I right.

Just thank you for your patience, and this could be closed.
Ttelmah



Joined: 11 Mar 2010
Posts: 19484

View user's profile Send private message

PostPosted: Sun Nov 08, 2015 3:20 pm     Reply with quote

However you _will_ find that once the chip starts operating other components connected to it, the reliability shoots down, if the decoupling is less than needed.....

I've often pointed out in the past that it is worth taking a look at a PC motherboard. Dozens of really high quality capacitors round the supply connections, and then ceramic capacitors next to just about every chip. Now manufacturers do not spend money pointlessly, so they know that these parts are needed.
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Nov 09, 2015 8:57 pm     Reply with quote

ING.remco wrote:
....I also tested if the decoupling capacitors were needed. But after removing them all the setup still functioned.


As you would expect, a car with the seat belts removed drives the same as when they were fitted. It is for the unexpected you need seat belts. Every IC should have at least one decoupling capacitor in close proximity to the VDD and VSS pins.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
ING.remco



Joined: 07 Nov 2015
Posts: 9

View user's profile Send private message

PostPosted: Wed Nov 11, 2015 2:13 pm     Reply with quote

There is no arguing in that. But the implementation of decoupling capacitors is to reduce the noise on the power supply going into the mcu. Therefore all measurement will be the "same".
On larger PCB's the generation of the different kinds of power rails is mostly on the edge and far away from the important IC's. Along the way all kind of noise will be picked up on the power lines and eventually come to the IC's. There the implement decoupling capacitor.
But if you have only one mcu and the power supply is almost on top of the mcu and if you go really far and place it in a metal box. There will be almost no noise than that is generated by the MCU and power regulation. And if the power regulation is also very stable and within the specs of the mcu a decoupling capacitor will not be that very useful for a test.

And this MCU is a good example. They RECOMMEND decoupling but the Vcap is REQUIRED. In other words you need minimum the Vcap to let the MCU work. But to improve we have some additional notes.

But of course when I design PCB's with all kinds off recommendation provided by the manufacturers, they will be implemented. Worst case is that you need them, best case you can leave them out (if that is possible).
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Wed Nov 11, 2015 3:57 pm     Reply with quote

There's good practice and there's practice that "gets you by". Endeavour to hold yourself to good design practices and you'll be able to sleep at night because of the confidence you'll have in your design(s). Do enough to get by, and you're going to have a short career. ....And little sleep just prior to leaving the profession.
gaugeguy



Joined: 05 Apr 2011
Posts: 303

View user's profile Send private message

PostPosted: Thu Nov 12, 2015 7:24 am     Reply with quote

ING.remco,
I have to disagree with you.
The primary purpose of the decoupling capacitors is not to reduce noise but to provide a low inductance current supply to the IC. This low inductance current supply is needed to provide the extremely short inrush of current required as digital gates switch states. Without this present, and depending on how many gates end up simultaneously switching state, the IC can experience a momentary, local brownout. All traces and all leads have inductance that increase with length. The only way for a decoupling capacitor to provide the low inductance current supply is to be physically close to the IC supply pins.
Ignore at your own peril...
Ttelmah



Joined: 11 Mar 2010
Posts: 19484

View user's profile Send private message

PostPosted: Thu Nov 12, 2015 8:11 am     Reply with quote

Hurrah!. Very Happy

and (of course) as soon as a processor starts to do more work (either just calculating, or - worse - switching more external lines), the local changes in demand can 'shoot up'.....
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