alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
[SOLVED] dsPIC33EP32MC202 rebooting |
Posted: Thu May 01, 2014 2:47 am |
|
|
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 |
|