
'****************************************************************
' Compiler directives
'****************************************************************
$sim
$regfile = "m32def.dat"                                     ' chip used
$hwstack = 32                                               ' default use 32 for the hardware stack
$swstack = 10                                               ' default use 10 for the SW stack
$framesize = 32                              
$crystal = 14745600
Baud = 19200

Startprogram:
                                              ' default use 40 for the frame space
Dim V As Byte
Input "Use this to ask a question " , V   '<------------------------------------------ Questo è il punto in cui si ferma e non riceve nessun carattere dalla seriale !!!!!!!!
Print "hai scritto " ; V

GoTo Startprogram






Dim Xx As Byte
Dim Yy As Byte
Dim Addrr As Byte
Dim Text As String * 10
Config Pind.2 = Input
Config Pind.3 = Input
Config Pind.4 = Input
Config Pind.5 = Input
Config Pind.6 = Input
Config Pind.7 = Input
Config Pinc.1 = Input
Xx = 0
Yy = 0
If Pind.2 = 0 Then Xx = 1
Yy = Yy + Xx
Xx = 0
If Pind.3 = 0 Then Xx = 2
Yy = Yy + Xx
Xx = 0
If Pind.4 = 0 Then Xx = 4
Yy = Yy + Xx
Xx = 0
If Pind.5 = 0 Then Xx = 8
Yy = Yy + Xx
Xx = 0
If Yy = 0 Then Yy = 1
Addrr = Yy

Xx = 0
Yy = 0

If Pind.6 = 0 Then Xx = 1
Yy = Yy + Xx
Xx = 0
If Pind.7 = 0 Then Xx = 2
Yy = Yy + Xx
Xx = 0
If Pinc.1 = 0 Then Xx = 4
Yy = Yy + Xx
Xx = 0


If Yy = 1 Then Baud = 2400
If Yy = 2 Then Baud = 4800
If Yy = 3 Then Baud = 9600
If Yy = 4 Then Baud = 19200
If Yy = 5 Then Baud = 38400
If Yy = 6 Then Baud = 57600
If Yy = 7 Then Baud = 115200

If Yy = 0 Then Text = "STOP LOOP"
If Yy = 1 Then Text = "2400 8N1"
If Yy = 2 Then Text = "4800 8N1"
If Yy = 3 Then Text = "9600 8N1"
If Yy = 4 Then Text = "19200 8N1"
If Yy = 5 Then Text = "38400 8N1"
If Yy = 6 Then Text = "57600 8N1"
If Yy = 7 Then Text = "115200 8N1"
Cls

Lcd "Addr :" ; Addrr ;
Lowerline
Lcd "Baud :" ; Yy ; " " ; Text
Waitms 200
If Yy = 0 Then Goto Startprogram


'modbus.lib contains the crcMB function
$lib "modbus.lbx"

'****************************************************************
'Il programma prosegue ed è molto lungo ma durante la compilazione non genera errori
'****************************************************************
