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 support@ccsinfo.com

[SOLVED] dsPIC33EP32MC202 rebooting

 
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] dsPIC33EP32MC202 rebooting
PostPosted: Thu May 01, 2014 2:47 am     Reply with quote

Hi All,

CCS 5.019

Anybody got an idea why the following code will restart the MCU. It happens every 30sec.
Code:

#include <33EP32MC202.h>
#device ADC=10

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES OSCIO                    //OSC2 is general purpose output
#FUSES NOCKSNOFSM                 //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES NOWINDIS                 //Watch Dog Timer in Window mode
#FUSES NOJTAG                   //JTAG disabled

#device ICSP=2
//FRC = 7.37MHz so CLK_FREQ should be multiple of this
#use delay(internal=36850000)

#include <stdint.h>

#use fast_io(A)
#use fast_io(B)
#define LED PIN_A3

int16_t VinADC, LEDTime;

void main(void) {

  setup_adc(ADC_CLOCK_DIV_8|ADC_TAD_MUL_16);
  setup_adc_ports(sAN0 | sAN1, VSS_VDD );
  set_adc_channel(0);
  output_a(0);
  output_b(0);
  set_tris_a(0x03);
  set_tris_b(0x0281);

  //Toggle LED when reboot to check for PIC resetting
  //Happens randomly
  output_toggle(LED);
  delay_ms(500);
  output_toggle(LED);
  delay_ms(500);
  output_toggle(LED);
  delay_ms(500);
  output_toggle(LED);
  delay_ms(500);
  output_toggle(LED);
 
  while (TRUE) {
    if (LEDTime++ > 5000) {
      output_toggle(LED);
      LEDTime = 0;
    }
    VinADC = read_adc() - 516;
  }
}



Regards


Last edited by alan on Thu May 01, 2014 3:45 am; edited 1 time in total
alan



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

View user's profile Send private message

PostPosted: Thu May 01, 2014 3:44 am     Reply with quote

I left the ICD-U64 in after programming and somehow the programmer resetted the MCU every 30sec. When unplugged the board does not reset anymore.

Regards
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