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] dsPIC33EP64GP506

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



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

View user's profile Send private message

[SOLVED] dsPIC33EP64GP506
PostPosted: Mon Oct 07, 2013 5:28 am     Reply with quote

Hi All

Battling to get the PIC to work. Seems to start and then fall over. Code use to test below.

Code:
#include <33EP64GP506.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOJTAG                   //JTAG disabled
#FUSES OSCIO                    //OSC2 is general purpose output
#FUSES NOCKSNOFSM               //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES NOIESO                   //Internal External Switch Over mode disabled
//#FUSES FRC
#device ICSP=1
#use delay(clock=7.37Mhz)

void main()
{
   while(TRUE)  {
     output_a(0xffff);
     output_d(0xffff);
     output_a(0x00);
     output_d(0x00);
  }
}


Above code output a high on the pins.
If I change to
Code:
     output_a(0x0000);
     output_d(0x0000);
     output_a(0xffff);
     output_d(0xffff);

still a high on the pins.
If I only use
Code:
    output_a(0x00);
     output_d(0x00);

a low on pins.

Pulling my hair out on this one, probably something stupid. Any help will be appreciated.

CCS 5.012

Regards


Last edited by alan on Mon Oct 07, 2013 6:46 am; edited 1 time in total
alan



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

View user's profile Send private message

PostPosted: Mon Oct 07, 2013 6:13 am     Reply with quote

Loaded the project in MPLABX and run the debugger.
If I stop the debugger, the PC will stop on one of the output_x Lines, which I assume then that the program are running. If I single step then output toggles correctly. If I then select run, no toggling, but when single stepping again it works. Confused Shocked
jeremiah



Joined: 20 Jul 2010
Posts: 1353

View user's profile Send private message

PostPosted: Mon Oct 07, 2013 6:16 am     Reply with quote

I would imagine measurement error in this case. You are switching super fast. Try putting a delay_ms(500) in between the highs and lows.

Code:

     delay_ms(500);
     output_a(0xffff);
     output_d(0xffff);
     delay_ms(500);
     output_a(0x00);
     output_d(0x00);
alan



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

View user's profile Send private message

PostPosted: Mon Oct 07, 2013 6:29 am     Reply with quote

Hi jeremiah

Just did that, and seems to work now. I just did that as I tried at 1st with an int that didn't work, so was worried that my clock not working. Can't believe the processor is so fast on 7.37MHz that it can't drive the output.

Thanks for your time.
Regards
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Mon Oct 07, 2013 7:44 am     Reply with quote

Is the pulse the length you expect?.
The chip may actually be running much faster than you think.

You need to use:
Code:

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOJTAG                   //JTAG disabled
#FUSES OSCIO                    //OSC2 is general purpose output
#FUSES NOCKSNOFSM               //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#device ICSP=1
#use delay(internal=7.37Mhz)


clock=7.37MHz, means 'I am giving you a 7.37MHz clock'
internal=7.37MHz, tells the compiler to _use_ the internal 7.37MHz clock.

By default, the PLL will be enabled, and I'm not sure what divider rate will be selected, so your chip may well have been running at something like 60Mhz....

Best Wishes
alan



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

View user's profile Send private message

PostPosted: Mon Oct 07, 2013 8:06 am     Reply with quote

Funny thing is internal or clock gives the same result. I added a delay_ms(50) between the statements and measured 50ms.

Regards
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Mon Oct 07, 2013 8:36 am     Reply with quote

Not 'funny', just luck. It depends what the default settings are, which changes with compiler version, and chips. With 'internal' specified, the compiler is meant (...), to calculate things for you. With 'clock' you are dependant on what the defaults happen to be. Several fuses recently changed meanings between CCS versions in some other areas, hence worth not pushing things. I wondered if the original code might have been producing a much higher frequency pulse than you expected, which suggested the 'possibility' that the CPU clock might be higher than expected....

Best Wishes
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