ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 12.06.2025
Просмотров: 8170
Скачиваний: 1
© MCS Electronics, 1995-2007 |
|
Rjmp myinput2 |
'no charac waiting |
so check again |
'we got something |
Popall |
|
Err = 0 |
'reset error |
In _temp1, UDR |
' Read character |
from UART |
'end of routine |
Return |
|
Myinput2: |
'with 4 MHz ca 10 |
If W > 1000000 Then |
|
sec delay |
'waited too long |
rjmp Myinput_exit |
|
Else |
'try again |
Goto Myinput1 |
|
End If |
|
Myinput_exit: |
'restore registers |
Popall |
|
Err = 1 |
'set error |
variable |
'fake enter so |
ldi R24, 13 |
|
INPUT will end |
|
Return |
$SERIALINPUT1
Action
Specifies that serial input of the second UART must be redirected.
Syntax
$SERIALINPUT1 = label
Remarks
Label |
The name of the assembler routine that must be called when a character is |
needed from the INPUT routine. The character must be returned in R24. |
|
With the redirection of the INPUT command, you can use your own input routines.
This way you can use other devices as input devices.
Note that the INPUT statement is terminated when a RETURN code (13) is received.
By default when you use INPUT or INKEY(), the compiler will expect data from the COM2 port. When you want to use a keyboard or remote control as the input device you can write a custom routine that puts the data into register R24 once it asks for this data.
See also
$SERIALOUTPUT1 , $SERIALINPUT , $SERIALOUTPUT
Example
See the $SERIALINPUT sample
$SERIALINPUT2LCD
page -244-
© MCS Electronics, 1995-2007
Action
This compiler directive will redirect all serial input to the LCD display instead of echo-ing to the serial port.
Syntax
$SERIALINPUT2LCD
Remarks
You can also write your own custom input or output driver with the $SERIALINPUT and $SERIALOUTPUT statements, but the $SERIALINPUT2LCD is handy when you use a LCD display. By adding only this directive, you can view all output form routines such as PRINT, PRINTBIN, on the LCD display.
See also
$SERIALINPUT , $SERIALOUTPUT , $SERIALINPUT1 , $SERIALOUTPUT1
Example
$regfile = "m48def.dat" $crystal = 4000000 $baud = 19200
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portc.7 , Rs = Portc.6
$serialinput2lcd Dim V As Byte
Do Cls
Input "Number " , V 'this will go to the LCD display
Loop
$SERIALOUTPUT
Action
Specifies that serial output must be redirected.
Syntax
$SERIALOUTPUT = label
Remarks
Label |
The name of the assembler routine that must be called when a character is |
send to the serial buffer (UDR). |
|
The character is placed into R24. |
|
page -245-
© MCS Electronics, 1995-2007
With the redirection of the PRINT and other serial output related commands, you can use your own routines.
This way you can use other devices as output devices.
See also
$SERIALINPUT , $SERIALINPUT2LCD , $SERIALINPUT1 , $SERIALOUTPUT1
Example
$regfile = "m48def.dat" $crystal = 4000000 $baud = 19200
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
$serialoutput = Myoutput 'your program goes here
Do
Print "Hello"
Loop
End
myoutput:
'perform the needed actions here 'the data arrives in R24
'just set the output to PORTB !outportb,r24
ret
$SERIALOUTPUT1
Action
Specifies that serial output of the second UART must be redirected.
Syntax
$SERIALOUTPUT1 = label
Remarks
Label |
The name of the assembler routine that must be called when a character is |
send to the serial buffer (UDR1). |
|
The character is placed into R24. |
|
With the redirection of the PRINT and other serial output related commands, you can use your own routines.
This way you can use other devices as output devices.
See also
$SERIALINPUT1 , $SERIALINPUT , $SERIALINPUT2LCD , $SERIALOUTPUT
Example
page -246-
© MCS Electronics, 1995-2007
See the $SERIALOUTPUT example
$SIM
Action
Instructs the compiler to generate empty wait loops for the WAIT and WAITMS statements. This to allow faster simulation.
Syntax
$SIM
Remarks
Simulation of a WAIT statement can take a long time especially when memory view windows are opened.
The $SIM compiler directive instructs the compiler to not generate code for WAITMS and WAIT. This will of course allows faster simulation.
When your application is ready you must remark the $SIM directive or otherwise the WAIT and WAITMS statements will not work as expected.
When you forget to remove the $SIM option and you try to program a chip you will receive a warning that $SIM was used.
See also
NONE
ASM
NONE
Example
$regfile = "m48def.dat" $crystal = 4000000 $baud = 19200
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
$sim Do
Wait 1
Print "Hello"
Loop
$SWSTACK
Action
Sets the available space for the software stack.
page -247-
© MCS Electronics, 1995-2007
Syntax
$SWSTACK = var
Remarks
Var A numeric decimal value.
While you can configure the SW Stack in Options, Compiler, Chip, it is good practice to put the value into your code. This way you do no need the cfg(configuration) file.
The $SWSTACK directive overrides the value from the IDE Options.
It is important that the $SWSTACK directive occurs in your main project file. It may not be included in an $include file as only the main file is parsed for $SWSTACK
See also
$HWSTACK , $FRAMESIZE
Example
'----------------------------------------------------------------------------- |
|
--- |
: adc.bas |
'name |
|
'copyright |
: (c) 1995-2005, MCS Electronics |
'purpose |
: demonstration of GETADC() function for 8535 or |
M163 micro |
: Mega163 |
'micro |
|
'suited for demo |
: yes |
'commercial addon needed |
: no |
'use in simulator |
: possible |
' Getadc() will also work for other AVR chips that have an ADC converter |
|
'----------------------------------------------------------------------------- |
|
--- |
' we use the M163 |
$regfile = "m163def.dat" |
|
$crystal = 4000000 |
|
$hwstack = 32 |
' default use 32 |
for the hardware stack |
'default use 10 |
$swstack = 10 |
|
for the SW stack |
'default use 40 |
$framesize = 40 |
|
for the frame space |
|
$TIMEOUT
Action
Enable timeout on the hardware UART 0 and UART1.
Syntax
$TIMEOUT = value
page -248-