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

24EP64GP204 Internal Clock PLL help (SOLVED - Thank you)

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



Joined: 09 Jun 2013
Posts: 153

View user's profile Send private message Visit poster's website

24EP64GP204 Internal Clock PLL help (SOLVED - Thank you)
PostPosted: Tue Aug 05, 2014 7:30 pm     Reply with quote

using 5.008 / 4.130

all i wanna do is make a hello world application (printf) or/LED blink

but i cannot get the clock to start!
i want to use the internal clock as the circuit im using doens't have a enough pins needed.

it DOES startup if i pull the chip out and put it back in, so clock does switch over to the internal, but after i mclr pulse, game over...

** PLEASE NOTE< this is a pic24 EP 64 GP 204...

here is the code.

Code:

#include <24EP64GP204.h>

/*
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOJTAG                   //JTAG disabled
#FUSES NOWINDIS                 //Watch Dog Timer in Window mode
#FUSES OSCIO                    //OSC2 is general purpose output
#FUSES NOCKSNOFSM               //Clock Switching is enabled, fail Safe clock monitor is disabled
#fuses FRC_PLL
//#FUSES   FRC_PS
#fuses PLLWAIT
*/


#FUSES ICSP2                    //ICD uses PGC2/PGD2 pins
#FUSES NOJTAG                   //JTAG disabled
#FUSES NOPLLWAIT                //Clock switch will not wait for the PLL lock signal
#FUSES NOWINDIS                 //Watch Dog Timer in Window mode
#FUSES OSCIO                    //OSC2 is general purpose output
#FUSES NOIOL1WAY                //Allows multiple reconfigurations of peripheral pins
#FUSES NOCKSNOFSM               //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES FRC_PLL                  //Internal Fast RC oscillator with PLL
//#FUSES FRC_PS
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOPROTECT

#use delay(CLOCK=80000000, INT=8MHz)



//#device ICSP=1

#pin_select U1TX=PIN_C8
#pin_select U1RX=PIN_C9

#define    test_test 0x20

#use rs232(UART1, baud=115200, stream=UART_PORT1, PARITY=N, BITS=8 )

#zero_ram


void main(){
   unsigned int8 balls;
   
  //

   //delay_ms(100);
   //setup_compare(1, COMPARE_PWM_CENTER | COMPARE_SYSTEM_CLOCK | COMPARE_SYNCHRONIZE | COMPARE_TRIG_SYNC_NONE);
   //set_compare_time(1, 16384, 49152);
   printf("did this work? \n\n******\nFLOPPY %u\n", test_test);

   balls=0;

   while(TRUE)
   {
      //TODO: User Code
      balls++;
      printf("did this work? %u\n"balls);
      delay_ms(200);
   }

}





Last edited by neochrome32 on Wed Aug 06, 2014 12:42 pm; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 05, 2014 7:35 pm     Reply with quote

This line of code compiles, but it doesn't work.
Quote:
printf("did this work? %u\n"balls);


You need the comma after the format specifier section:
Code:
printf("did this work? %u\n", balls);
neochrome32



Joined: 09 Jun 2013
Posts: 153

View user's profile Send private message Visit poster's website

PostPosted: Tue Aug 05, 2014 7:49 pm     Reply with quote

oddly, that compiles, and it does print out! but i've recompiled with the correction, same issue

Code:

void main(){
     unsigned int8 event1;
     
  //

     //delay_ms(100);
   //setup_compare(1, COMPARE_PWM_CENTER | COMPARE_SYSTEM_CLOCK | COMPARE_SYNCHRONIZE | COMPARE_TRIG_SYNC_NONE);
   //set_compare_time(1, 16384, 49152);
     printf("did this work? \n\n******\nFLOPPY %u\n", test_ID);

     event1=0;

   while(TRUE)
   {
      //TODO: User Code
      event1++;
      printf("did this work? %u\n",event1);
      delay_ms(200);
   }

}



there are no icons just now
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 05, 2014 9:49 pm     Reply with quote

What happens if you get rid of all oscillator-related fuses and just let the
compiler handle it ? Delete all these fuses:
Quote:

#FUSES FRC_PLL
#FUSES NOPLLWAIT
#FUSES NOCKSNOFSM
#FUSES NOIESO

Change your #use delay to this:
Code:
#use delay(internal=8MHz)
neochrome32



Joined: 09 Jun 2013
Posts: 153

View user's profile Send private message Visit poster's website

PostPosted: Tue Aug 05, 2014 10:10 pm     Reply with quote

compiler says "Invalid Osc Target Frequancy"

if i put it to 80M
it does run, but ONLY if i again take the chip out and plug it back in!

MCLR stops it working

(mclr has a pull up resistor of 4.7k)
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Tue Aug 05, 2014 11:17 pm     Reply with quote

First thing, the internal oscillator runs at 7.37MHz.
Just try

#use delay(internal=7.37MHz)

Without the other clock fuses.

Then, are you sure you are compiling in 'release' mode, not 'debug' mode?.
If you are using MPLAB, it defaults to debug, and if the code is in debug mode, the ICSP pins need to have resistors on them to stop the processor going to halt mode. Your unplug/plug, might be allowing the chip to wake in this case.

How quick is your PSU rise time?. Look at DC17 in the data sheet. Does your supply meet this?. If not, then consider adding an external reset circuit. This may be the reason for needing MCLR to be pulsed.
neochrome32



Joined: 09 Jun 2013
Posts: 153

View user's profile Send private message Visit poster's website

PostPosted: Wed Aug 06, 2014 8:35 am     Reply with quote

Hello Ttelmah,

i did set the int=8M and tried also INT=737000

i am using both 4.130 and 5.008 and neither of these compilers will start it, and NODEBUG is set in the fuses!

i do have to use MPLAB X to upload the code using the PICKIT 3

i am connecting it all with the PICKIT 3 Power supply only, i have to turn on the power before it will even program.. looking at the DC17 again.. thought i had that right...

there is resistors on the ICSP pins (but not used) i got the PGMD/C connected directly to the programmer... doesn't say i need resistors in series in it tho.....
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Wed Aug 06, 2014 9:32 am     Reply with quote

NODEBUG in the fuses, will be _overridden_ if you are using MPLAB. It's one of those 'thinks it knows better' things.
Make absolutely sure that if you are using MPLAB, you change to release mode. Otherwise it will override this fuse....
neochrome32



Joined: 09 Jun 2013
Posts: 153

View user's profile Send private message Visit poster's website

PostPosted: Wed Aug 06, 2014 9:44 am     Reply with quote

the dumb thing then is, where in mplab is the release mode? (as im not compiling using mplab)
neochrome32



Joined: 09 Jun 2013
Posts: 153

View user's profile Send private message Visit poster's website

PostPosted: Wed Aug 06, 2014 11:52 am     Reply with quote

its a problem with the circuit board... as i put it all on a breadboard and seems to be ok.. SO VERY STRANGE

will keep posted.. thank you guys

oh dear lord! i missed out the AVSS, and AVDD!! its the cause of the issue! I CANT BELIEVE I MISSED IT!!
right there on the "basic recommended connection"

i feel very dumb right here! LOL

Thank you very much Smile
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