View previous topic :: View next topic |
Author |
Message |
neochrome32
Joined: 09 Jun 2013 Posts: 153
|
24EP64GP204 Internal Clock PLL help (SOLVED - Thank you) |
Posted: Tue Aug 05, 2014 7:30 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 05, 2014 7:35 pm |
|
|
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); |
|
|
![](templates/subSilver/images/spacer.gif) |
neochrome32
Joined: 09 Jun 2013 Posts: 153
|
|
Posted: Tue Aug 05, 2014 7:49 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 05, 2014 9:49 pm |
|
|
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) |
|
|
![](templates/subSilver/images/spacer.gif) |
neochrome32
Joined: 09 Jun 2013 Posts: 153
|
|
Posted: Tue Aug 05, 2014 10:10 pm |
|
|
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) |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19366
|
|
Posted: Tue Aug 05, 2014 11:17 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
neochrome32
Joined: 09 Jun 2013 Posts: 153
|
|
Posted: Wed Aug 06, 2014 8:35 am |
|
|
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..... |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19366
|
|
Posted: Wed Aug 06, 2014 9:32 am |
|
|
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.... |
|
![](templates/subSilver/images/spacer.gif) |
neochrome32
Joined: 09 Jun 2013 Posts: 153
|
|
Posted: Wed Aug 06, 2014 9:44 am |
|
|
the dumb thing then is, where in mplab is the release mode? (as im not compiling using mplab) |
|
![](templates/subSilver/images/spacer.gif) |
neochrome32
Joined: 09 Jun 2013 Posts: 153
|
|
Posted: Wed Aug 06, 2014 11:52 am |
|
|
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](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
|