ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 12.06.2025
Просмотров: 8269
Скачиваний: 1
© MCS Electronics, 1995-2007
disadvantage is that it blocks program execution just like a normal un-buffered PRINT would do.
ASM
Routines called from MCS.LIB :
_CHECKSENDCHAR1. This is an ISR that gets called when ever the transmission buffer is empty.
Since UDRE1 interrupt is used , you can not use this interrupt anymore. Unless you modify the _CheckSendChar1 routine of course.
When you use the PRINT statement to send data to the serial port, the UDRE1 interrupt will be enabled. And so the _CheckSendChar1 routine will send the data fromthe buffer.
See also
CONFIG SERIALIN1
Example
'----------------------------------------------------------------------------- |
|
------------ |
: rs232bufferout1.bas |
'name |
|
'copyright |
: (c) 1995-2005, MCS Electronics |
'purpose |
: how to use a serial output buffer on the second |
UART |
this sample will only work for chips with a seond |
' |
|
UART like |
the M161 and M128 |
' |
|
'micro |
: Mega161 |
'suited for demo |
: yes |
'commercial addon needed |
: no |
'----------------------------------------------------------------------------- |
|
------------ |
|
$regfile = "m162def.dat" |
' specify the used |
micro |
' used crystal |
$crystal = 4000000 |
|
frequency |
' use baud rate |
$baud = 9600 |
|
$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 |
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Config Com2 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
'setup to use a serial output buffer 'and reserve 20 bytes for the buffer Config Serialout1 = Buffered , Size = 20
Open "Com1:" For Binary As #1
'It is important since UDRE interrupt is used that you enable the interrupts
Enable Interrupts
Print #1 , "Hello world"
Do Wait 1
page -380-