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

SOLVED:dsPIC33EP512GM604 With Internal FRC

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



Joined: 05 Jul 2010
Posts: 129

View user's profile Send private message

SOLVED:dsPIC33EP512GM604 With Internal FRC
PostPosted: Wed Jul 23, 2014 9:43 am     Reply with quote

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
temtronic



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

View user's profile Send private message

PostPosted: Wed Jul 23, 2014 9:52 am     Reply with quote

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
alan



Joined: 12 Nov 2012
Posts: 357
Location: South Africa

View user's profile Send private message

PostPosted: Wed Jul 23, 2014 9:53 am     Reply with quote

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
Geps



Joined: 05 Jul 2010
Posts: 129

View user's profile Send private message

PostPosted: Wed Jul 23, 2014 10:28 am     Reply with quote

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,
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Thu Jul 24, 2014 2:11 pm     Reply with quote

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).
Geps



Joined: 05 Jul 2010
Posts: 129

View user's profile Send private message

PostPosted: Fri Jul 25, 2014 3:38 am     Reply with quote

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...?
Geps



Joined: 05 Jul 2010
Posts: 129

View user's profile Send private message

PostPosted: Fri Jul 25, 2014 3:05 pm     Reply with quote

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! Embarassed

All working now thanks to CCS Support.
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Sat Jul 26, 2014 1:53 am     Reply with quote

Gentle scream.... Smile

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.
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