🇩🇪
Zitat von: Dansen in 09.08.2022, 12:17:05 CESTWenn allerdings die Initialisierung des OPTION Registers auskommentiert wird, funktioniert Garnichts mehr. Ich lade allerdings hierzu gerne zum selbst testen ein.Es funktioniert nur der Ausgang GP2 nicht mehr, weil:
;Set up the assembler options (Chip type, clock source, other bits and pieces)
LIST p=10F206, r=DEC
#include <P10F206.inc>
__CONFIG _MCLRE_OFF & _WDTE_OFF & _OSC_INTRC
;********************************************************************************
;Set aside memory locations for variables
DELAYTEMP EQU 8
DELAYTEMP2 EQU 9
SysWaitTempMS EQU 10
SysWaitTempMS_H EQU 11
;********************************************************************************
;Vectors
;Start of program memory page 0
ORG 0
BASPROGRAMSTART
;Call initialisation routines
call INITSYS
;Start of the main program
;''A demonstration program for GCGB and GCB.
;''--------------------------------------------------------------------------------------------------------------------------------
;''This program blink one LED on GPIO.0 (bit 1) using the Toggle command.
;''The LED must be attached via appropiate resistors.
;''@author EvanV plus works of HughC
;''@licence GPL
;''@version 1.0a
;''***************************************************************************
;Chip Settings
;dir GPIO out
clrw
tris GPIO
;none specified in the example. All byte variables are defined upon use.
;Do Forever
SysDoLoop_S1
;set GPIO.1 on
bsf GPIO,1
;Wait 500 ms
movlw 244
movwf SysWaitTempMS
movlw 1
movwf SysWaitTempMS_H
call Delay_MS
;set GPIO.1 off
bcf GPIO,1
;wait 500 ms
movlw 244
movwf SysWaitTempMS
movlw 1
movwf SysWaitTempMS_H
call Delay_MS
;Loop
goto SysDoLoop_S1
SysDoLoop_E1
;You can toggle any number of pins by addressing the bits using this method
;Toggle PORT, BIT
BASPROGRAMEND
sleep
goto BASPROGRAMEND
;********************************************************************************
Delay_MS
incf SysWaitTempMS_H, F
DMS_START
movlw 142
movwf DELAYTEMP2
DMS_OUTER
movlw 1
movwf DELAYTEMP
DMS_INNER
decfsz DELAYTEMP, F
goto DMS_INNER
decfsz DELAYTEMP2, F
goto DMS_OUTER
decfsz SysWaitTempMS, F
goto DMS_START
decfsz SysWaitTempMS_H, F
goto DMS_START
retlw 0
;********************************************************************************
INITSYS
;CMCON0 = 7
movlw 7
movwf CMCON0
;movlw b'11001111'
movlw B'11001111'
;option
option
;GPIO = 0
clrf GPIO
retlw 0
;********************************************************************************
END
#include <xc.h>
#pragma config WDTE = OFF // Watchdog Timer (WDT disabled)
#pragma config CP = OFF // Code Protect (Code protection off)
#pragma config MCLRE = OFF // Master Clear Enable (GP3/MCLR pin fuction is digital I/O, MCLR internally tied to VDD)
#define RA0 GPIObits.GP0 // INPUT AUXON
#define RA1 GPIObits.GP1 // INPUT CARON
#define RA2 GPIObits.GP2 // OUTPUT RELPWM
void main(void) {
OPTION = 0b10010000; // DIESES REGISTER MUSS INITIALISIERT WERDEN SONST RUINIERT ES DEINE WOCHE
CMCON0 = 0b00000000; // Komparator Register ebenfalls mit 0 initialisieren(muss nicht unbedingt sein)
TRIS = 0b11111011; //GP2 als Output
while(1){
if(RA0 == 1 || RA1 == 1)
{
RA2 = 1;
_delay(500); //~500us delay
}
else
{
RA2 = 0;
}
}
return;
}
#include <xc.h>
void main()
{
TRIS = 0x0d; //Bit 1 Ausgang
GPIO = 0x02; //Bit 1 setzen
while(1); //Endlosschleife
}
#include <xc.h>
void main()
{
TRIS = 0b111101;
GPIO = 0b000010;
for(;;)
{
;
}
}