Scale For Radio Error Compile

Pytania, kody i porady dotyczące nie tylko Bascom.
ODPOWIEDZ
weako
Posty: 11
Rejestracja: 22 mar 2020, 14:37

Scale For Radio Error Compile

Post autor: weako » 22 mar 2020, 14:47

Hello everyone,
I am a newbie in this forum, and i am interested to joint to this forum.

I found below code on this website and i trying to do compiling, some pin of connection, lcd and processor has been changes, once compile i got an error, so please anyone here can help me to solved i happen that error from.

Here are the code :
  1. $regfile = "m8def.dat"
  2. $crystal = 8000000
  3. $hwstack = 64
  4. $swstack = 64
  5. $framesize = 64
  6.  
  7.  
  8.  
  9. Config Submode = New
  10.  
  11.  
  12. Config Lcd = 16x2
  13. Config Lcdpin = Pin , Db4 = Portc . 2 , Db5 = Portc . 3 , Db6 = Portc . 4 , Db7 = Portc . 5 , E = Portc . 1 , Rs = Portc . 0
  14.  
  15. Deflcdchar 1 , 32 , 32 , 32 , 32 , 32 , 4 , 4 , 21
  16.  
  17. Deflcdchar 2 , 16 , 16 , 16 , 16 , 16 , 20 , 20 , 21
  18. Deflcdchar 3 , 8 , 8 , 8 , 8 , 8 , 12 , 12 , 29
  19. Deflcdchar 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 21
  20. Deflcdchar 5 , 2 , 2 , 2 , 2 , 2 , 6 , 6 , 23
  21. Deflcdchar 6 , 1 , 1 , 1 , 1 , 1 , 5 , 5 , 21
  22.  
  23.  
  24. Cursor Off Noblink Cls
  25.  
  26.  
  27. '16 boxes x 5 positions = 80 // The scale can be divided ' 87.5MHz - 108MHz 1080-875 = 205 205/80 = 2.5625 <<<< 256 (Shift 8)
  28.  
  29.  
  30. Dim Value As Word
  31. Dim Scale As String * 16
  32. Dim Relay As Word
  33.  
  34. Scale = String(16 , 1 )
  35.  
  36. '--------- [FOR ENCODER ONNLY] ---------------------------------
  37.  Config Portd . 2 = Input : Set Portd . 2 : Encoder_a Alias Pind . 2
  38.  Config Portd . 3 = Input : Set Portd . 3 : Encoder_b Alias Pind . 3
  39.  Config Portd . 7 = Input : Set Portd . 7 : Encoder_sw Alias Pind . 7
  40.  Config Porta . 0 = Output : Relay Alias Porta . 0 : Reset Relay
  41.  
  42. Config Int0 = Falling : Enable Int0 : On Int0 Encoder_isr Nosave Dim Encoder_turn_left As Byte , Encoder_turn_right As Byte
  43.  
  44.  
  45. Enable Interrupts                                           ' ----------------------------------------------- --------------
  46.  
  47.  
  48. Sub Draw_scale(byval Value As Word )
  49.  
  50.  
  51.   Local Help_w As Word Local Help_b As Byte Local X_pos As Byte Local Char As Byte
  52.  
  53.  
  54.   Local Freq As String * 5
  55.    Freq = Str(value )
  56.     Freq = Format(freq , "00.0" )
  57.  
  58.    Locate 1 , 4
  59.      If Value < 1000 Then Lcd Chr(32 ) Lcd Freq ; "MHz"
  60.  
  61.  
  62.   Lowerline : Lcd Scale
  63.  
  64.   Help_w = Value - 875
  65.    Help_w = Help_w * 100
  66.      Shift Help_w , Right , 8
  67.     Help_b = Help_w
  68.  
  69.    X_pos = Help_b / 5
  70.    X_pos = X_pos + 1
  71.     Char = Help_b Mod 5
  72.     Char = Char + 2
  73.  
  74.    Locate 2 , 1 : Lcd Scale
  75.     Locate 2 , X_pos : Lcd Chr(char )
  76.  
  77.  End Sub
  78.  
  79.  
  80.   Value = 892
  81.  
  82. Call Draw_scale(value )
  83.  
  84. To If Encoder_turn_right > 0 Then Decr Encoder_turn_right
  85.  
  86.       If Value < 1079 Then                                  '79 zero based = 80 Incr Value
  87.          Call Draw_scale(value ) End If
  88.  
  89.  
  90.  
  91.  End If
  92.  
  93.  If Encoder_turn_left > 0 Then Decr Encoder_turn_left
  94.  
  95.  
  96.       If Value > 875 Then Decr Value
  97.          Call Draw_scale(value ) End If
  98.  
  99.  
  100.  
  101.  End If
  102.  
  103.  
  104. Loop End
  105.  
  106.  
  107. Encoder_isr :
  108.  
  109.   $ Asm
  110.   PUSH R24
  111.   ! in R24 , sreg
  112.   PUSH R24
  113.   $ End Asm
  114.  
  115.  If Encoder_b = 1 Then
  116.     Encoder_turn_right = 1
  117.   Else
  118.     Encoder_turn_left = 1
  119.   End If                                                    'Tuned with NoSave Tool
  120.  
  121.  
  122.   $ Asm
  123.   POP R24
  124.   ! out sreg , r24
  125.   POP R24
  126.   $ End Asm
  127.  
  128. Return
Thanks.
Wea
Nie masz wymaganych uprawnień, aby zobaczyć pliki załączone do tego posta.
Awatar użytkownika
niveasoft
Posty: 1216
Rejestracja: 17 sie 2015, 12:13
Kontakt:

Re: Scale For Radio Error Compile

Post autor: niveasoft » 22 mar 2020, 15:31

I think that this is some syntax/formating problem. For example in the config port you cant do "space" between "dot" and port pin number.

They should be written like this "PORTD.2" So no spaces :D

I`ll try to fix your code ;)
Nie masz wymaganych uprawnień, aby zobaczyć pliki załączone do tego posta.
Awatar użytkownika
niveasoft
Posty: 1216
Rejestracja: 17 sie 2015, 12:13
Kontakt:

Re: Scale For Radio Error Compile

Post autor: niveasoft » 22 mar 2020, 15:40

It compiles now just fine ;)
  1. $regfile = "m8def.dat"
  2. $crystal = 8000000
  3. $hwstack = 64
  4. $swstack = 64
  5. $framesize = 64
  6.  
  7.  
  8.  
  9. Config Submode = New
  10.  
  11.  
  12. Config Lcd = 16x2
  13. Config Lcdpin = Pin , Db4 = Portc . 2 , Db5 = Portc . 3 , Db6 = Portc . 4 , Db7 = Portc . 5 , E = Portc . 1 , Rs = Portc . 0
  14.  
  15. Deflcdchar 1 , 32 , 32 , 32 , 32 , 32 , 4 , 4 , 21
  16.  
  17. Deflcdchar 2 , 16 , 16 , 16 , 16 , 16 , 20 , 20 , 21
  18. Deflcdchar 3 , 8 , 8 , 8 , 8 , 8 , 12 , 12 , 29
  19. Deflcdchar 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 21
  20. Deflcdchar 5 , 2 , 2 , 2 , 2 , 2 , 6 , 6 , 23
  21. Deflcdchar 6 , 1 , 1 , 1 , 1 , 1 , 5 , 5 , 21
  22.  
  23. Cursor Off , Noblink
  24. Cls
  25.  
  26.     '16 boxes x 5 positions = 80 // The scale can be divided ' 87.5MHz - 108MHz 1080-875 = 205 205/80 = 2.5625 <<<< 256 (Shift 8)
  27.  
  28. Dim Value As Word
  29. Dim Scale As String * 16
  30. Dim Relay As Word
  31.  
  32. Scale = String(16 , 1 )
  33.  
  34.     '--------- [FOR ENCODER ONNLY] ---------------------------------
  35. Config Portd.2 = Input : Set Portd.2 : Encoder_a Alias Pind.2
  36. Config Portd.3 = Input : Set Portd.3 : Encoder_b Alias Pind.3
  37. Config Portd.7 = Input : Set Portd.7 : Encoder_sw Alias Pind.7
  38.      'Config Porta.0 = Output : Relay Alias Porta . 0 : Reset Relay
  39.  
  40. Config Int0 = Falling : Enable Int0 : On Int0 Encoder_isr Nosave
  41.  
  42. Dim Encoder_turn_left As Byte , Encoder_turn_right As Byte
  43.  
  44.  
  45. Enable Interrupts                                           ' ----------------------------------------------- --------------
  46.  
  47.  
  48. Sub Draw_scale(byval Value As Word )
  49.  
  50.  
  51.    Local Help_w As Word
  52.    Local Help_b As Byte
  53.    Local X_pos As Byte
  54.    Local Char As Byte
  55.  
  56.    Local Freq As String * 5
  57.    Freq = Str(value )
  58.    Freq = Format(freq , "00.0" )
  59.  
  60.    Locate 1 , 4
  61.    If Value < 1000 Then Lcd Chr(32 )
  62.     Lcd Freq ; "MHz"
  63.  
  64.  
  65.    Lowerline : Lcd Scale
  66.  
  67.    Help_w = Value - 875
  68.    Help_w = Help_w * 100
  69.    Shift Help_w , Right , 8
  70.    Help_b = Help_w
  71.  
  72.    X_pos = Help_b / 5
  73.    X_pos = X_pos + 1
  74.    Char = Help_b Mod 5
  75.    Char = Char + 2
  76.  
  77.    Locate 2 , 1 : Lcd Scale
  78.    Locate 2 , X_pos : Lcd Chr(char )
  79.  
  80. End Sub
  81.  
  82.  
  83. Value = 892
  84.  Call Draw_scale(value )
  85.  
  86. Do
  87.    If Encoder_turn_right > 0 Then
  88.     Decr Encoder_turn_right
  89.  
  90.       If Value < 1079 Then                                  '79 zero based = 80 Incr Value
  91.        Incr Value
  92.        Call Draw_scale(value )
  93.       End If
  94.  
  95.    End If
  96.  
  97.    If Encoder_turn_left > 0 Then
  98.     Decr Encoder_turn_left
  99.  
  100.  
  101.       If Value > 875 Then
  102.        Decr Value
  103.        Call Draw_scale(value )
  104.       End If
  105.  
  106.    End If
  107.  
  108. Loop
  109. End
  110.  
  111. Encoder_isr:
  112.  
  113. $asm
  114. !PUSH R24
  115. ! in R24 , sreg
  116. !PUSH R24
  117. $end Asm
  118.  
  119. If Encoder_b = 1 Then
  120.    Encoder_turn_right = 1
  121. Else
  122.    Encoder_turn_left = 1
  123. End If                                                 'Tuned with NoSave Tool
  124.  
  125. $asm
  126. !POP R24
  127. ! out sreg , r24
  128. !POP R24
  129. $end Asm
  130.  
  131. Return
weako
Posty: 11
Rejestracja: 22 mar 2020, 14:37

Re: Scale For Radio Error Compile

Post autor: weako » 22 mar 2020, 18:48

Hello Niveasoft,
Thank you for your reply.

I just copy paste your code to bascom compiler, and i have still an error.

The error at start in line 113 ($ Persons) :
  1. $ Persons
  2. ! PUSH R24
  3. ! in R24 , sreg
  4. ! PUSH R24
  5. $end Asm
  6.  
  7. If Encoder_b = 1 Then
  8.    Encoder_turn_right = 1
  9. Else
  10.    Encoder_turn_left = 1
  11. End If
  12. 'Tuned with NoSave Tool
  13. $ Persons
  14. !POP R24
  15. ! out sreg , r24
  16. !POP R24
  17. $end Asm
  18.  
  19. Return
Attached is a picture an error.

Thanks.
Wea.
Nie masz wymaganych uprawnień, aby zobaczyć pliki załączone do tego posta.
Awatar użytkownika
niveasoft
Posty: 1216
Rejestracja: 17 sie 2015, 12:13
Kontakt:

Re: Scale For Radio Error Compile

Post autor: niveasoft » 22 mar 2020, 18:53

This is some encoding problem for your language. Look how it should be displayed and is displayed for me.
Watch 113 line ;)
Nie masz wymaganych uprawnień, aby zobaczyć pliki załączone do tego posta.
weako
Posty: 11
Rejestracja: 22 mar 2020, 14:37

Re: Scale For Radio Error Compile

Post autor: weako » 22 mar 2020, 19:13

Hello Niveasoft,
Yes you right, that code now working to compile, that problem i read this forum with english translate, so it will translate some code inside $asm become $persons.

Tomorrow i will try to test on real hardware.

Anyway, i just need the function of rotary encoder only with the calculation of frequency, without bargraph
  1. Deflcdchar 1 , 32 , 32 , 32 , 32 , 32 , 4 , 4 , 21
  2.  
  3. Deflcdchar 2 , 16 , 16 , 16 , 16 , 16 , 20 , 20 , 21
  4. Deflcdchar 3 , 8 , 8 , 8 , 8 , 8 , 12 , 12 , 29
  5. Deflcdchar 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 21
  6. Deflcdchar 5 , 2 , 2 , 2 , 2 , 2 , 6 , 6 , 23
  7. Deflcdchar 6 , 1 , 1 , 1 , 1 , 1 , 5 , 5 , 21
So which one that apart of bargraph should be remove/delete.

Thanks.
Wea.
weako
Posty: 11
Rejestracja: 22 mar 2020, 14:37

Re: Scale For Radio Error Compile

Post autor: weako » 24 mar 2020, 0:53

Hello Niveasoft,
Last night, i trying to run that code on the real hardware, it's working very well.
Could you please tell how to that to control a TSA5511 ic prescaller, through an I2C interface.

Thanks.
Wea.
ODPOWIEDZ