Hi,
My microcontroller stops working within 24 hours. When i reset it, it works again for 24 hours.
I tried several things but i cannot see what i am doing wrong in the code.
Who can help me ?Code:DEVICE 16F628A ;Gebruik een 16F628A type CONFIG HS_OSC, WDT_OFF, PWRTE_ON, LVP_OFF, MCLRE_OFF ALL_DIGITAL TRUE ;Alle ingangen digitaal XTAL 20 ;Kristal van 20MHz HSERIAL_BAUD = 2400 ' Set baud rate to 2400 HSERIAL_RCSTA = %10010000 ' Enable serial port and continuous receive HSERIAL_TXSTA = %00100000 ' Enable transmit and asynchronous mode HSERIAL_CLEAR = ON ' Optionally clear the buffer before receiving PORTB_PULLUPS ON ;On-chip pull-up weerstanden actief ; 76543210 PORTA = %00000000 ;Alle niveaus van PORTA eerst laag maken PORTB = %00000000 ;Alle niveaus van PORTB eerst laag maken TRISA = %00000000 ;Alle PORTA poorten omschakelen als ingang TRISB = %11111111 ; 1 = Input 0 = Output ;Logische constanten SYMBOL K1 = PORTA.2 SYMBOL S1 = PORTB.7 SYMBOL S2 = PORTB.6 DIM SerData AS BYTE DIM Opdracht AS BYTE DIM S1_Status AS BIT DIM S2_Status AS BIT S1_Status = 0 S2_Status = 0 CLEAR ;Wis alle RAM geheugen HSEROUT["Program Started"] MainProgram: WHILE 1 = 1 ;Oneindige lus IF S1 = 0 THEN ;S1 is Ingedrukt IF S1_Status = 1 THEN HSEROUT["11"] S1_Status = 0 ENDIF ELSE IF S1_Status = 0 THEN HSEROUT["10"] S1_Status = 1 ENDIF ENDIF IF S2 = 0 THEN ;S1 is gesloten. IF S2_Status = 1 THEN HSEROUT["21"] S2_Status = 0 ENDIF ELSE IF S2_Status = 0 THEN HSEROUT["20"] S2_Status = 1 ENDIF ENDIF HSERIN 10, timeout,[DEC SerData] SELECT SerData CASE 10 LOW K1 CASE 11 HIGH K1 CASE 12 HIGH K1 DELAYMS 50 LOW K1 END SELECT WEND timeout: GOTO MainProgram END ;Einde programma
Bookmarks