Forum: Mikrocontroller und Digitale Elektronik PIC 18F2585 automatisches RESET


von Martin K. (mkkirchner)


Lesenswert?

Hallo,

Ich habe einen PIC 18F2585 in einer schaltung.
Als Testsoftware lasse ich einfach ein relais anziehen und eien LED 
blinken.

Der Pic macht ziemlich genau alle 2 Minuten und einigen Seckunden 
selbstständig ein RESET und startet neu.

Hat jemand eine Idee an was das liegen könnte ??

Vielen Dank

mk

von PIC N. (eigo) Benutzerseite


Lesenswert?

Der komplette Programmcode wäre nett =)

von Martin K. (mkkirchner)


Lesenswert?

Hier das Testprogram:
1
#include "D:\Projeckte\OpenBMS\test.h"
2
3
 int32 c;
4
void main()
5
{
6
7
   setup_adc_ports(AN0_TO_AN9|VSS_VREF);
8
   setup_adc(ADC_CLOCK_DIV_32|ADC_TAD_MUL_20);
9
   setup_spi(FALSE);
10
   setup_wdt(WDT_OFF);
11
   setup_timer_0(RTCC_INTERNAL);
12
   setup_timer_1(T1_DISABLED);
13
   setup_timer_2(T2_DISABLED,0,1);
14
   setup_vref(FALSE);
15
   setup_oscillator(False);
16
17
   // TODO: USER CODE!!
18
  c=0; 
19
  output_high(PIN_B0);
20
  while(1)                          
21
  {   
22
  c++;  
23
  output_high(PIN_C5);
24
   printf("+%ld\r\n",c);
25
   delay_ms(500);    
26
   output_low(PIN_C5);
27
   delay_ms(500);
28
  }
29
}
1
#include <18F2585.h>
2
#device adc=16
3
4
#FUSES NOWDT                    //No Watch Dog Timer
5
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
6
#FUSES HS                       //High speed Osc (> 4mhz)
7
#FUSES NOPROTECT                //Code not protected from reading
8
#FUSES NOBROWNOUT               //No brownout reset
9
#FUSES BORV21                   //Brownout reset at 2.1V
10
#FUSES NOPUT                    //No Power Up Timer
11
#FUSES NOCPD                    //No EE protection
12
#FUSES STVREN                   //Stack full/underflow will cause reset
13
#FUSES NODEBUG                  //No Debug mode for ICD
14
#FUSES LVP                      //Low Voltage Programming on B3(PIC16) or B5(PIC18)
15
#FUSES NOWRT                    //Program memory not write protected
16
#FUSES NOWRTD                   //Data EEPROM not write protected
17
#FUSES IESO                     //Internal External Switch Over mode enabled
18
#FUSES FCMEN                    //Fail-safe clock monitor enabled
19
#FUSES PBADEN                   //PORTB pins are configured as analog input channels on RESET
20
#FUSES BBSIZ4K                  //4K words Boot Block size
21
#FUSES NOWRTC                   //configuration not registers write protected
22
#FUSES NOWRTB                   //Boot block not write protected
23
#FUSES NOEBTR                   //Memory not protected from table reads
24
#FUSES NOEBTRB                  //Boot block not protected from table reads
25
#FUSES NOCPB                    //No Boot Block code protection
26
#FUSES LPT1OSC                  //Timer1 configured for low-power operation
27
#FUSES MCLR                     //Master Clear pin enabled
28
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
29
30
#use delay(clock=20000000)
31
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

MK

von Martin S. (drunkenmunky)


Lesenswert?

Für welchen Compiler soll denn der Code sein?

Les doch mal das RCON Register aus, dann weißt du was den Reset 
ausgelöst hat.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.