de code in C
Code:
/**************************************************************
Description:
Author(s):
History:
Copyrights(C) 2003
***************************************************************/
//RS232 settings
#pragma RS232_TXPORT GPIO
#pragma RS232_RXPORT GPIO
#pragma RS232_TXPIN 4
#pragma RS232_RXPIN 0
#pragma RS232_BAUD 2400
//Timing settings
#pragma CLOCK_FREQ 4000000
//////////////////////////////////////////////
// Main program entry
//////////////////////////////////////////////
char code;
char POORTJE@0x06;
void output_low() {
asm {
movlw 1
bcf GPIO,1
tris GPIO
}
}
void output_high() {
asm {
movlw 1
bsf GPIO,1
tris GPIO
}
}
void shortburst()
{
output_high();
delay_ms(250);
delay_ms(250);
delay_ms(200);
output_low();
}
void longburst()
{
output_high();
delay_s (1);
delay_ms(250);
delay_ms(250);
output_low();
}
main()
{
//Init ports
asm {
movlw 1
tris GPIO
}
output_high();
delay_s( '2' );
output_low();
while(1)
{
if(POORTJE && 00000001b)
{
delay_ms(1);
if(POORTJE && 00000001b)
{
code = getchar();
if (code == 'a')shortburst();
if (code == 'w')shortburst();
if (code == 's')longburst();
}
}
/*
ingang meten,
hoog -> even wachten in eerste 10%
nogsteeds hoog -> code
*/
}
}
de code in Assembler
Code:
; This file was generated by C2C-plus compiler version 5.0.5e
include "p12C509A.inc"
;Variables *****************************************
_C5X_tmp equ 0x07 ;1
param00_delay_ms equ 0x08 ;2
param00_delay_s equ 0x0a ;1
_code equ 0x0b ;1
_rs232_delay_counter equ 0x0c ;1
_counter__c2c_getchar equ 0x0d ;1
_ret__c2c_getchar equ 0x0e ;1
_POORTJE equ 0x06 ;1
ORG 0
movwf OSCCAL
goto start__code
_output_low
goto _output_low__code
_output_high
goto _output_high__code
_shortburst
goto _shortburst__code
_delay_ms
goto _delay_ms__code
_longburst
goto _longburst__code
_delay_s
goto _delay_s__code
__c2c_getchar
goto __c2c_getchar__code
__c2c_rs232_delay2
goto __c2c_rs232_delay2__code
__c2c_rs232_delay
goto __c2c_rs232_delay__code
start__code
_main__code
movlw 1
tris GPIO
call _output_high
movlw D'50'
movwf param00_delay_s
call _delay_s
call _output_low
label_0003
bcf FSR, 5
movf _POORTJE, W
andlw 0xFF
btfsc STATUS, Z
goto label_0006
movlw 1
label_0006
andlw D'255'
btfsc STATUS, Z
goto label_0003
movlw D'1'
movwf param00_delay_ms
call _delay_ms
bcf FSR, 5
movf _POORTJE, W
andlw 0xFF
btfsc STATUS, Z
goto label_0008
movlw 1
label_0008
andlw D'255'
btfsc STATUS, Z
goto label_0007
call __c2c_getchar
movf _C5X_tmp, W
movwf _code
movlw D'97'
subwf _code, W
btfss STATUS, Z
goto label_0013
call _shortburst
label_0013
movlw D'119'
subwf _code, W
btfss STATUS, Z
goto label_0014
call _shortburst
label_0014
movlw D'115'
subwf _code, W
btfss STATUS, Z
goto label_0015
call _longburst
label_0015
label_0007
label_0005
goto label_0003
label_0004
_main__end
_output_low__code
movlw 1
bcf GPIO,1
tris GPIO
retlw 0
_output_low__end
_output_high__code
movlw 1
bsf GPIO,1
tris GPIO
retlw 0
_output_high__end
_shortburst__code
call _output_high
movlw D'250'
movwf param00_delay_ms
call _delay_ms
movlw D'250'
movwf param00_delay_ms
call _delay_ms
movlw D'200'
movwf param00_delay_ms
call _delay_ms
call _output_low
retlw 0
_shortburst__end
_delay_ms__code
label_0000
movlw D'142'
movwf param00_delay_ms+1
nop
nop
label_0001
nop
nop
nop
nop
decfsz param00_delay_ms+1, F
goto label_0001
nop
decfsz param00_delay_ms, F
goto label_0000
nop
retlw 0
_delay_ms__end
_longburst__code
call _output_high
movlw D'1'
movwf param00_delay_s
call _delay_s
movlw D'250'
movwf param00_delay_ms
call _delay_ms
movlw D'250'
movwf param00_delay_ms
call _delay_ms
call _output_low
retlw 0
_longburst__end
_delay_s__code
label_0002
movlw D'250'
movwf param00_delay_ms
call _delay_ms
movlw D'250'
movwf param00_delay_ms
call _delay_ms
movlw D'250'
movwf param00_delay_ms
call _delay_ms
movlw D'250'
movwf param00_delay_ms
call _delay_ms
decfsz param00_delay_s, F
goto label_0002
retlw 0
_delay_s__end
__c2c_getchar__code
movlw D'8'
movwf _counter__c2c_getchar
clrf _ret__c2c_getchar
label_0009
btfsc GPIO, 0
goto label_0009
call __c2c_rs232_delay2
btfsc GPIO, 0
goto label_0009
label_0011
call __c2c_rs232_delay
rrf _ret__c2c_getchar, F
bcf _ret__c2c_getchar, 7
btfsc GPIO, 0
bsf _ret__c2c_getchar, 7
decfsz _counter__c2c_getchar, F
goto label_0011
call __c2c_rs232_delay
movf _ret__c2c_getchar, W
movwf _C5X_tmp
retlw 0
__c2c_getchar__end
__c2c_rs232_delay2__code
movlw D'67'
movwf _rs232_delay_counter
label_0010
decfsz _rs232_delay_counter, F
goto label_0010
retlw 0
__c2c_rs232_delay2__end
__c2c_rs232_delay__code
movlw D'134'
movwf _rs232_delay_counter
label_0012
decfsz _rs232_delay_counter, F
goto label_0012
retlw 0
__c2c_rs232_delay__end
END