View previous topic :: View next topic |
Author |
Message |
Geps
Joined: 05 Jul 2010 Posts: 129
|
SOLVED:dsPIC33EP512GM604 With Internal FRC |
Posted: Wed Jul 23, 2014 9:43 am |
|
|
Hi,
I'm starting my first 'dsPIC33/ICD3/CCS 5.025/MPLabX' project having spent the past couple years on the PIC18/Pickit2/CCS 4.XXX combo and seem to have fallen at the first hurdle...
I'm trying to get an LED to blink using the internal FRC clock source...whilst programming the led lights briefly (but doesn't when the output_high line is commented out) so I presume it's a clock related problem?
Any pointers would be appreciated,
Thanks,
Code: |
#include <33EP512GM604.h>
#fuses FRC,NOWDT,NOPROTECT,NOPR
#use delay(clock = 7372800)
void main() {
output_high(PIN_C6);
while (TRUE) {
delay_ms(1000);
}
}
|
Last edited by Geps on Fri Jul 25, 2014 3:04 pm; edited 1 time in total |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9173 Location: Greensville,Ontario
|
|
Posted: Wed Jul 23, 2014 9:52 am |
|
|
1) code as shown ONLY turns on LED...
you need the 'output_toggle()' function to blink it.
2) you also need to have the loop...toggle,delay,toggle,delay
hth
jay |
|
![](templates/subSilver/images/spacer.gif) |
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
|
Posted: Wed Jul 23, 2014 9:53 am |
|
|
You switch the output on and then never off.
Code: | #include <33EP512GM604.h>
#fuses NOWDT,NOPROTECT,NOPR
#use delay(clock = 7372800)
void main() {
while (TRUE) {
output_high(PIN_C6);
delay_ms(1000);
output_low(PIN_C6);
delay_ms(1000);
}
} |
Does the output_high(PIN_C6) switch the LED on or OFF?
Regards |
|
![](templates/subSilver/images/spacer.gif) |
Geps
Joined: 05 Jul 2010 Posts: 129
|
|
Posted: Wed Jul 23, 2014 10:28 am |
|
|
Sorry guys! I meant to say that the LED doesn't stay on hence I took out the output_off/toggle line of code.
Only time it lights is during programming when output_high(PIN_C6) is included - if you comment it out, then the LED doesn't light at all...
Cheers, |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19366
|
|
Posted: Thu Jul 24, 2014 2:11 pm |
|
|
How is the LED wired?.
Classic reason for the behaviour you describe, would be incorrect wiring of the LED. Connecting it directly to the PIC pin without a current limiting resistor (or with one that is too small). |
|
![](templates/subSilver/images/spacer.gif) |
Geps
Joined: 05 Jul 2010 Posts: 129
|
|
Posted: Fri Jul 25, 2014 3:38 am |
|
|
Through a 56R resistor down to Vcc. If anything the resistor is actually too large a value... I'm using (was, I've switch to using a scope now as mentioned below) emerald green:
Datasheet: http://docs-europe.electrocomponents.com/webdocs/0026/0900766b80026845.pdf
Forward voltage: 2.2V typ
Forward current: 25mA max
Supply 3.25V
I've emailed CCS support and they suggested a test program (below) but it's not flashing...
Things that I've now tried/done:
Removed the LED from the board and used a 'scope on the pin to check for any activity and it's just 0V.
Changed pins to C7 and A7 and still nothing
The pic has 3 100nf decoupling capacitors on the pairs of supply pins and a low ESR cap on Vcap as per the datasheet notes. Supply is 3.25V from the ICD3.
It's on a custom PCB, but only thing I've populated is the LED, current limiting resistor, ICD header, PIC and caps as listed above.
Code: | #include <33EP512GM604.h>
#fuses NOWDT,NOPROTECT
#use delay(internal = 7370000)
void main() {
while (TRUE) {
output_high(PIN_C7);
delay_ms(1000);
output_low(PIN_C7);
delay_ms(1000);
}
} |
Would anyone have the same hardware that they could just test the program on please? I'm trying to figure out if it's an issue with the firmware, or a simple hardware change that my inexperience with dsPICs has caused me to miss...? |
|
![](templates/subSilver/images/spacer.gif) |
Geps
Joined: 05 Jul 2010 Posts: 129
|
|
Posted: Fri Jul 25, 2014 3:05 pm |
|
|
Geps wrote: | or a simple hardware change that my inexperience with dsPICs has caused me to miss...? |
Turns out it was the good old MCLR pullup!
All working now thanks to CCS Support. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19366
|
|
Posted: Sat Jul 26, 2014 1:53 am |
|
|
Gentle scream....
Very obvious. Must admit I thought from your post, that you were using some sort of 'off the shelf' development board, that would therefore have a pull-up. It is often the 'obvious' that sneaks out to catch you. |
|
![](templates/subSilver/images/spacer.gif) |
|