ewandeur
- 28th March 2008, 16:49
Hello !
I'm using a PIC12F675 to emulate a IR remote control, using a ASM routine to create 38Khz - 40 Khz pulses extracted from a microchip app.note (Keith Curtis AN91094).
The program compiles with no problem, but didn't work at all.
I've tried many code variations, but it still didn't work, poor me!!
Is there some trick with the compiler? setup or something?
Did someone use only PB instead of using ASM subroutines?
Please HELP!!!!
There is my last try...
@ DEVICE pic12F675
@ DEVICE PIC12F675, XT_OSC
@ DEVICE pic12F675, WDT_ON
@ DEVICE pic12F675, PWRT_ON
@ DEVICE pic12F675, MCLR_OFF
@ DEVICE pic12F675, BOD_ON
' Internal Oscillator
' Enable watch dog timer
' Enable power up timer
' Disable MCLR pin
' Enable brown out detect
DEFINE OSC 3
TRISIO.0 = 0 ' set GPIO.0 as output
TRISIO.1 = 1 ' set GPIO.0 as input
TRISIO.2 = 1 ' set GPIO.0 as input
CMCON = 7 ' turn off analog comparator
ADCON0.0 = 0
ADCON0.1 = 0
ADCON0.2 = 0
OPTION_REG.7 = 0
VRCON = 0
ANSEL = 0
'// Setup IR bit widths / carrier cycle times
Header CON 96 '// Header = (96 * 25uS) = 2.4mS burst
Zero CON 24 '// Zero = (24 * 25uS) = 0.6mS burst
One CON 48 '// One = (48 * 25uS) = 1.2mS burst
'// Define variables
Cycles VAR BYTE '// Holds number of 40KHz carrier cycles
i var byte
Loop:
if gpio.1 = 1 then
cycles = header
gosub pulse
cycles = zero
gosub dark
cycles = zero
gosub pulse
cycles = zero
gosub dark
endif
if gpio.2 = 1 then
cycles = header
gosub pulse
cycles = zero
gosub dark
cycles = one
gosub pulse
endif
Pulse: '// Emits # of 38.461 kHz bursts held in variable Cycles
for i = 1 to cycles
ASM ;// with auto delay between bursts
bsf GPIO, 0 ;// 1uS, LED=on [need 25uS total
goto $+1 ;// 3uS (2uS per goto $+1)
goto $+1 ;// 5uS
goto $+1 ;// 7uS
goto $+1 ;// 9uS
goto $+1 ;// 11uS
goto $+1 ;// 13uS
bcf GPIO, 0 ;// 14uS, LED=off
decfsz _Cycles,F ;// 24uS
goto $+1 ;// 16uS
goto $+1 ;// 18uS
goto $+1 ;// 20uS
goto $+1 ;// 22uS
retlw 0 ;// 23uS (Testing condition????)
ENDASM
next i
return
Dark:
for i = 1 to cycles
ASM ;// with auto delay between bursts
bcf GPIO, 0 ;// 1uS, LED=on [need 25uS total
goto $+1 ;// 3uS (2uS per goto $+1)
goto $+1 ;// 5uS
goto $+1 ;// 7uS
goto $+1 ;// 9uS
goto $+1 ;// 11uS
goto $+1 ;// 13uS
goto $+1 ;// 13uS
goto $+1 ;// 13uS
goto $+1 ;// 16uS
goto $+1 ;// 18uS
goto $+1 ;// 20uS
goto $+1 ;// 20uS
ENDASM
next i
return
I'm using a PIC12F675 to emulate a IR remote control, using a ASM routine to create 38Khz - 40 Khz pulses extracted from a microchip app.note (Keith Curtis AN91094).
The program compiles with no problem, but didn't work at all.
I've tried many code variations, but it still didn't work, poor me!!
Is there some trick with the compiler? setup or something?
Did someone use only PB instead of using ASM subroutines?
Please HELP!!!!
There is my last try...
@ DEVICE pic12F675
@ DEVICE PIC12F675, XT_OSC
@ DEVICE pic12F675, WDT_ON
@ DEVICE pic12F675, PWRT_ON
@ DEVICE pic12F675, MCLR_OFF
@ DEVICE pic12F675, BOD_ON
' Internal Oscillator
' Enable watch dog timer
' Enable power up timer
' Disable MCLR pin
' Enable brown out detect
DEFINE OSC 3
TRISIO.0 = 0 ' set GPIO.0 as output
TRISIO.1 = 1 ' set GPIO.0 as input
TRISIO.2 = 1 ' set GPIO.0 as input
CMCON = 7 ' turn off analog comparator
ADCON0.0 = 0
ADCON0.1 = 0
ADCON0.2 = 0
OPTION_REG.7 = 0
VRCON = 0
ANSEL = 0
'// Setup IR bit widths / carrier cycle times
Header CON 96 '// Header = (96 * 25uS) = 2.4mS burst
Zero CON 24 '// Zero = (24 * 25uS) = 0.6mS burst
One CON 48 '// One = (48 * 25uS) = 1.2mS burst
'// Define variables
Cycles VAR BYTE '// Holds number of 40KHz carrier cycles
i var byte
Loop:
if gpio.1 = 1 then
cycles = header
gosub pulse
cycles = zero
gosub dark
cycles = zero
gosub pulse
cycles = zero
gosub dark
endif
if gpio.2 = 1 then
cycles = header
gosub pulse
cycles = zero
gosub dark
cycles = one
gosub pulse
endif
Pulse: '// Emits # of 38.461 kHz bursts held in variable Cycles
for i = 1 to cycles
ASM ;// with auto delay between bursts
bsf GPIO, 0 ;// 1uS, LED=on [need 25uS total
goto $+1 ;// 3uS (2uS per goto $+1)
goto $+1 ;// 5uS
goto $+1 ;// 7uS
goto $+1 ;// 9uS
goto $+1 ;// 11uS
goto $+1 ;// 13uS
bcf GPIO, 0 ;// 14uS, LED=off
decfsz _Cycles,F ;// 24uS
goto $+1 ;// 16uS
goto $+1 ;// 18uS
goto $+1 ;// 20uS
goto $+1 ;// 22uS
retlw 0 ;// 23uS (Testing condition????)
ENDASM
next i
return
Dark:
for i = 1 to cycles
ASM ;// with auto delay between bursts
bcf GPIO, 0 ;// 1uS, LED=on [need 25uS total
goto $+1 ;// 3uS (2uS per goto $+1)
goto $+1 ;// 5uS
goto $+1 ;// 7uS
goto $+1 ;// 9uS
goto $+1 ;// 11uS
goto $+1 ;// 13uS
goto $+1 ;// 13uS
goto $+1 ;// 13uS
goto $+1 ;// 16uS
goto $+1 ;// 18uS
goto $+1 ;// 20uS
goto $+1 ;// 20uS
ENDASM
next i
return