The following program are actually working in a infrared remote control little car almost a year ago. I try to program another pic with the same program and fail to work. I traced the problem to the instruccion While-Wend and replaced them with conventional if-then-else and work perfectly. Do you tell me why this has happen?. Thanks in advance for your halp. and I have the lattest GCBASIC version.
#define LCD_IO 2 ' Two line LCD
#define LCD_DB GPIO.1 ' Data Bit (Cable amarillo)
#define LCD_CB GPIO.2 ' Clock Bit (Cable azul)
' Naranja +5, Azul tierra
dir gpio b'00001000'
#define infra gpio.3
dir infra in
locate 0,5
print "NEC003"
getbits:
cmn = 0 ' b '00000000'
while infra on : wend ' espera que el pulso de arranque caiga
for ik = 0 to 7 ' contar 8 bits
while infra off : wend ' gasta tiempo mientras el pulso es bajo
while infra on : sl=sl+1 : wend ' incrementa sl mientras el pulso is alto
print sl
if sl > 170 then set cmn.7 on ' si el pulso es 'ancho' entonces el bit es = "1"
if ik = 7 then goto Fin ' bit7 es ok, no rotar
rotate cmn right simple
sl = 0 ' acumulador en cero
next ' probar otro comando
Fin:
cls
locate 1,0 ' se usa solo para
print cmn ' ver valores
wait 10 ms ' y verificar
goto getbits
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The following program are actually working in a infrared remote control little car almost a year ago. I try to program another pic with the same program and fail to work. I traced the problem to the instruccion While-Wend and replaced them with conventional if-then-else and work perfectly. Do you tell me why this has happen?. Thanks in advance for your halp. and I have the lattest GCBASIC version.
#chip 12F675, 4
#config BODEN_OFF, MCLRE_OFF, INTRC_OSC_NOCLKOUT
#define LCD_IO 2 ' Two line LCD
#define LCD_DB GPIO.1 ' Data Bit (Cable amarillo)
#define LCD_CB GPIO.2 ' Clock Bit (Cable azul)
' Naranja +5, Azul tierra
dir gpio b'00001000'
#define infra gpio.3
dir infra in
locate 0,5
print "NEC003"
getbits:
cmn = 0 ' b '00000000'
while infra on : wend ' espera que el pulso de arranque caiga
for ik = 0 to 7 ' contar 8 bits
while infra off : wend ' gasta tiempo mientras el pulso es bajo
while infra on : sl=sl+1 : wend ' incrementa sl mientras el pulso is alto
print sl
if sl > 170 then set cmn.7 on ' si el pulso es 'ancho' entonces el bit es = "1"
if ik = 7 then goto Fin ' bit7 es ok, no rotar
rotate cmn right simple
sl = 0 ' acumulador en cero
next ' probar otro comando
Fin:
cls
locate 1,0 ' se usa solo para
print cmn ' ver valores
wait 10 ms ' y verificar
goto getbits