;BYTE
Dim Command As Byte ;RC5/RC6 command byte
Dim CommandOud As Byte
Dim Systeem As Byte ;RC5/RC6 systeem byte
Dim SysteemOud As Byte
Dim BD1 As Byte ;Byte Dummy
;BIT
Dim CodeRC5X As Bit ;1 als het een RC5X code betreft anders...
Dim CodeRC6 As Bit ;...1 als het een RC6 code betreft (anders RC5)
Dim CodeRC6Oud As Bit ;Als er gewisseld wordt tussen RC6 en RC5/RC5X moet LCD ook ge-updated worden
Dim ToggBit As Bit ;RC5/RC6 toggle bit
Dim Waarde As Bit ;Argument voor subroutine "BitOphalen"
Dim ID1 As Bit ;bIt Dummy
Wait 50 10ms ;LC-Display stabilisering
Cls
Print "IR Uitlezen"
GoTo Start ;Spring over de subroutines\
;SUBROUTINES
BitOphalen:
BD1 = 0
Waarde = PORTA.4 ;Maak Waarde 0 of 1 afhankelijk van ontvangen IR code
Do While PORTA.4 = Waarde And BD1 < 50 ;Niveau moet binnen een bepaalde tijd veranderen
BD1 = BD1 + 1
Loop
If 50 = BD1 Then
Locate 0,0
Print "Error " ;Niet binnen de tijd een niveau-verandering
End if
Wait 110 10us ;950 - 1600
Return
;HOOFDPROGRAMMA
Start:
BD1 = 0
Wait While PORTA.4 = 1 ;Wacht op ontvangst
Do While PORTA.4 = 0 And BD1 < 52
BD1 = BD1 + 1
Loop
If BD1 < 52 Then
Locate 0,0
Print "Error "
End If
CommandOud = Command ;Bewaar oude waarden voor herstel in geval van een error
SysteemOud = Systeem
;Zoek uit welk protocol-----------------
BD1 = 0
Command = 0 ;Eerst 0 maken omdat RC5/RC5X bits 6 & 7 niet overschrijft, als RC6 deze eerder hoog heeft gemaakt, blijven deze hoog (=fout)
Systeem = 0 ;Eerst 0 maken omdat RC5/RC5X bits 5,6,7 niet overschrijft, als RC6 deze eerder hoog heeft gemaakt, blijven deze hoog (=fout)
Do While BD1 < 255 And PORTA.4 = 0
BD1 = BD1 + 1
Loop
CodeRC5X = 0
CodeRC6 = 0
Select Case BD1
Case 25 To 90 ;RC5X
CodeRC5X = 1
Command.6 = 1
Wait 128 10us ; 900 - 1700 (RC5X)
Case > 90 ;RC6
CodeRC6 = 1
Case Else ;RC5
Wait 218 10us ;1800 - 2600 (RC5)
End Select
; --------------------------------------
If CodeRC6 = 1 Then
' Wait WHILE PORTA.4 = 1 ;00 Vervalt hier door protocol onderzoek
' Wait WHILE PORTA.4 = 0 ;1 Vervalt hier door protocol onderzoek
Wait While PORTA.4 = 1 ;00
Wait While PORTA.4 = 0 ;1
Wait While PORTA.4 = 1 ;0
Wait While PORTA.4 = 0 ;1
Wait While PORTA.4 = 1 ;0
Wait 200 10us ;Wacht tot de laatste '1' van de header voorbijkomt (1778us), hierdoor val je middenin de eerste togglebit
ToggBit = PORTA.4
Wait While ToggBit = PORTA.4 ;Wacht tot geinverteerde deel van togglebit komt
Wait 110 10us ;1000 - 1200; Zodoende val je in het eerste systeem bit
GoSub BitOphalen
Systeem.7 = Waarde
GoSub BitOphalen
Systeem.6 = Waarde
GoSub BitOphalen
Systeem.5 = Waarde
End if
If CodeRC6 = 0 Then
GoSub BitOphalen
LED_Toggle = Waarde
End If
GoSub BitOphalen
Systeem.4 = Waarde
GoSub BitOphalen
Systeem.3 = Waarde
GoSub BitOphalen
Systeem.2 = Waarde
GoSub BitOphalen
Systeem.1 = Waarde
GoSub BitOphalen
Systeem.0 = Waarde
If CodeRC6 = 1 Then ;RC5/RC5X hebben geen 6e en 7e bits
GoSub BitOphalen
Command.7 = Waarde
GoSub BitOphalen
Command.6 = Waarde
End If
GoSub BitOphalen
Command.5 = Waarde
GoSub BitOphalen
Command.4 = Waarde
GoSub BitOphalen
Command.3 = Waarde
GoSub BitOphalen
Command.2 = Waarde
GoSub BitOphalen
Command.1 = Waarde
GoSub BitOphalen
Command.0 = Waarde
If Systeem <> SysteemOud Or Command <> CommandOud Or CodeRC6 <> CodeRC6Oud Then ;Zonder deze regel knippert het LCD tijdens ontvangst (door CLS)
Cls
If CodeRC5X = 1 Then
Print "RC5X"
ElseIf CodeRC6 = 1 Then
Print "RC6"
End If
If CodeRC5X = 0 And CodeRC6 = 0 Then
Print "RC5"
End If
Print " Protocol"
Wait 100 10ms ;Tijd voor aanduiding RC5, RC5X of RC6 protocol
;Deze regel NIET bovenaan Start zetten, anders wordt hij ook gereset als er een Glitch komt
CodeRC6Oud= CodeRC6 ;Als er gewisseld wordt tussen RC6 en RC5/RC5X moet LCD ook ge-updated worden
GoTo Start
When I try to compile this, I get a number of assembly errors, but I have absolutely zero knowledge of assembly, so I can't find out what is going wrong.
These are the errors that occur during the assembling.
compiled.asm:15:Error [174] Illegal character 'T' in numeric constant
compiled.asm:15:Error [103] syntax error
compiled.asm:245:Error [174] Illegal character 'T' in numeric constant
compiled.asm:258:Error [103] syntax error
compiled.asm:325:Error [108] Illegal Character (,)
compiled.asm:325:Error [128] Missing argument(s).
compiled.asm:327:Error [108] Illegal Character (,)
compiled.asm:327:Error [128] Missing argument(s).
compiled.asm:393:Error [103] syntax error
compiled.asm:407:Error [103] syntax error
compiled.asm:448:Error [174] Illegal character 'T' in numeric constant
compiled.asm:448:Error [108] Illegal Character (,)
compiled.asm:448:Error [128] Missing argument(s).
Can anybody help me?
I have updated GCBasic to the latest version.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
1) Make the PORTA.4 pin an input by specifying "dir PORTA in"
2) BitOphalen: should be a sub so, "sub BitOphalen"
3) Don't think you can use conditions with select case, so use IF conditions instead.
So like,
If BD1 >= 25 AND BD1 <= 90 Then
CodeRC5X = 1
Command.6 = 1
End If
4) The assembler doesn't care for multiple instances of like goto's or labels. So "GoTo Start ;Spring over de subroutines\ " is illegal, and also unnecessary, now that there is a "sub BitOphalen".
Good Luck!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for your help, now I am able to compile and assemble the program, and load it into my PIC.
However, the program doesn't seem to get past the sub-routine. Even when I put a Print-command directly after Start:, it is not printed on my screen...
Do you have any idea what the problem might be?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to build a program to receive IR-signals with a TSOP IR-module.
This is the program I have written so far.
#chip 16F628A, 4
#config INTOSC_OSC_NOCLKOUT, WDT_OFF, PWRTE_ON, BODEN_OFF, LVP_OFF
#define LCD_IO 4
#define LCD_DB4 PORTB.4
#define LCD_DB5 PORTB.5
#define LCD_DB6 PORTB.6
#define LCD_DB7 PORTB.7
#define LCD_RS PORTB.3
#define LCD_RW PORTB.0
#define LCD_Enable PORTB.2
;BYTE
Dim Command As Byte ;RC5/RC6 command byte
Dim CommandOud As Byte
Dim Systeem As Byte ;RC5/RC6 systeem byte
Dim SysteemOud As Byte
Dim BD1 As Byte ;Byte Dummy
;BIT
Dim CodeRC5X As Bit ;1 als het een RC5X code betreft anders...
Dim CodeRC6 As Bit ;...1 als het een RC6 code betreft (anders RC5)
Dim CodeRC6Oud As Bit ;Als er gewisseld wordt tussen RC6 en RC5/RC5X moet LCD ook ge-updated worden
Dim ToggBit As Bit ;RC5/RC6 toggle bit
Dim Waarde As Bit ;Argument voor subroutine "BitOphalen"
Dim ID1 As Bit ;bIt Dummy
Wait 50 10ms ;LC-Display stabilisering
Cls
Print "IR Uitlezen"
GoTo Start ;Spring over de subroutines\
;SUBROUTINES
BitOphalen:
BD1 = 0
Waarde = PORTA.4 ;Maak Waarde 0 of 1 afhankelijk van ontvangen IR code
Do While PORTA.4 = Waarde And BD1 < 50 ;Niveau moet binnen een bepaalde tijd veranderen
BD1 = BD1 + 1
Loop
If 50 = BD1 Then
Locate 0,0
Print "Error " ;Niet binnen de tijd een niveau-verandering
End if
Wait 110 10us ;950 - 1600
Return
;HOOFDPROGRAMMA
Start:
BD1 = 0
Wait While PORTA.4 = 1 ;Wacht op ontvangst
Do While PORTA.4 = 0 And BD1 < 52
BD1 = BD1 + 1
Loop
If BD1 < 52 Then
Locate 0,0
Print "Error "
End If
CommandOud = Command ;Bewaar oude waarden voor herstel in geval van een error
SysteemOud = Systeem
;Zoek uit welk protocol-----------------
BD1 = 0
Command = 0 ;Eerst 0 maken omdat RC5/RC5X bits 6 & 7 niet overschrijft, als RC6 deze eerder hoog heeft gemaakt, blijven deze hoog (=fout)
Systeem = 0 ;Eerst 0 maken omdat RC5/RC5X bits 5,6,7 niet overschrijft, als RC6 deze eerder hoog heeft gemaakt, blijven deze hoog (=fout)
Do While BD1 < 255 And PORTA.4 = 0
BD1 = BD1 + 1
Loop
CodeRC5X = 0
CodeRC6 = 0
Select Case BD1
Case 25 To 90 ;RC5X
CodeRC5X = 1
Command.6 = 1
Wait 128 10us ; 900 - 1700 (RC5X)
Case > 90 ;RC6
CodeRC6 = 1
Case Else ;RC5
Wait 218 10us ;1800 - 2600 (RC5)
End Select
; --------------------------------------
If CodeRC6 = 1 Then
' Wait WHILE PORTA.4 = 1 ;00 Vervalt hier door protocol onderzoek
' Wait WHILE PORTA.4 = 0 ;1 Vervalt hier door protocol onderzoek
Wait While PORTA.4 = 1 ;00
Wait While PORTA.4 = 0 ;1
Wait While PORTA.4 = 1 ;0
Wait While PORTA.4 = 0 ;1
Wait While PORTA.4 = 1 ;0
Wait 200 10us ;Wacht tot de laatste '1' van de header voorbijkomt (1778us), hierdoor val je middenin de eerste togglebit
ToggBit = PORTA.4
Wait While ToggBit = PORTA.4 ;Wacht tot geinverteerde deel van togglebit komt
Wait 110 10us ;1000 - 1200; Zodoende val je in het eerste systeem bit
GoSub BitOphalen
Systeem.7 = Waarde
GoSub BitOphalen
Systeem.6 = Waarde
GoSub BitOphalen
Systeem.5 = Waarde
End if
If CodeRC6 = 0 Then
GoSub BitOphalen
LED_Toggle = Waarde
End If
GoSub BitOphalen
Systeem.4 = Waarde
GoSub BitOphalen
Systeem.3 = Waarde
GoSub BitOphalen
Systeem.2 = Waarde
GoSub BitOphalen
Systeem.1 = Waarde
GoSub BitOphalen
Systeem.0 = Waarde
If CodeRC6 = 1 Then ;RC5/RC5X hebben geen 6e en 7e bits
GoSub BitOphalen
Command.7 = Waarde
GoSub BitOphalen
Command.6 = Waarde
End If
GoSub BitOphalen
Command.5 = Waarde
GoSub BitOphalen
Command.4 = Waarde
GoSub BitOphalen
Command.3 = Waarde
GoSub BitOphalen
Command.2 = Waarde
GoSub BitOphalen
Command.1 = Waarde
GoSub BitOphalen
Command.0 = Waarde
If Systeem <> SysteemOud Or Command <> CommandOud Or CodeRC6 <> CodeRC6Oud Then ;Zonder deze regel knippert het LCD tijdens ontvangst (door CLS)
Cls
If CodeRC5X = 1 Then
Print "RC5X"
ElseIf CodeRC6 = 1 Then
Print "RC6"
End If
If CodeRC5X = 0 And CodeRC6 = 0 Then
Print "RC5"
End If
Print " Protocol"
Wait 100 10ms ;Tijd voor aanduiding RC5, RC5X of RC6 protocol
Cls
Print "Sys:"
LCDInt (Systeem)
Locate 1,0
Print "Com:"
LCDInt (Command)
End If
;Deze regel NIET bovenaan Start zetten, anders wordt hij ook gereset als er een Glitch komt
CodeRC6Oud= CodeRC6 ;Als er gewisseld wordt tussen RC6 en RC5/RC5X moet LCD ook ge-updated worden
GoTo Start
When I try to compile this, I get a number of assembly errors, but I have absolutely zero knowledge of assembly, so I can't find out what is going wrong.
These are the errors that occur during the assembling.
compiled.asm:15:Error [174] Illegal character 'T' in numeric constant
compiled.asm:15:Error [103] syntax error
compiled.asm:245:Error [174] Illegal character 'T' in numeric constant
compiled.asm:258:Error [103] syntax error
compiled.asm:325:Error [108] Illegal Character (,)
compiled.asm:325:Error [128] Missing argument(s).
compiled.asm:327:Error [108] Illegal Character (,)
compiled.asm:327:Error [128] Missing argument(s).
compiled.asm:393:Error [103] syntax error
compiled.asm:407:Error [103] syntax error
compiled.asm:448:Error [174] Illegal character 'T' in numeric constant
compiled.asm:448:Error [108] Illegal Character (,)
compiled.asm:448:Error [128] Missing argument(s).
Can anybody help me?
I have updated GCBasic to the latest version.
A few things to move your code along:
1) Make the PORTA.4 pin an input by specifying "dir PORTA in"
2) BitOphalen: should be a sub so, "sub BitOphalen"
3) Don't think you can use conditions with select case, so use IF conditions instead.
So like,
If BD1 >= 25 AND BD1 <= 90 Then
CodeRC5X = 1
Command.6 = 1
End If
4) The assembler doesn't care for multiple instances of like goto's or labels. So "GoTo Start ;Spring over de subroutines\ " is illegal, and also unnecessary, now that there is a "sub BitOphalen".
Good Luck!
Thank you for your help, now I am able to compile and assemble the program, and load it into my PIC.
However, the program doesn't seem to get past the sub-routine. Even when I put a Print-command directly after Start:, it is not printed on my screen...
Do you have any idea what the problem might be?
Edit: I found out I forgot a "End Sub" command, but if I put that one in, I get a lot of ASM errors again...