View previous topic :: View next topic |
Author |
Message |
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Thu Dec 05, 2019 2:55 pm Post subject: serialin |
|
|
it semms a misnomer not really but it can be confusing
serialin1 corresponds to com2 and not to com1 as indicated in the help
Quote: | Some chips have multiple HW UARTS. Use the following parameter values:
· SERIALIN or SERIALIN0 : first UART/UART0 named Com1
· SERIALIN1 : second UART/UART1 named com2
· SERIALIN2 : third UART/UART2
· SERIALIN3 : fourth UART/UART3
|
in fact this is working
Code: | Config Com1 = 115200 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Echo Off
Config Serialin0 = Buffered , Size = 30 'RX from Terminal
Open "COM1:" For Binary As #1
Const Usb = 1
'*****************************************************************
'* CONFIG BUFFERED USART FOR NEXTION *
'*****************************************************************
Config Com2 = 38400 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Config Serialin1 = Buffered , Size = 30 'RX
Config Serialout1 = Buffered , Size = 30 'TX
Open "COM2:" For Binary As #2
Const Nex = 2 |
I tryed to use the USB port as debug for a Nextion display and I have a lot of error with the definition of serialin
now it's work
JP
(BASCOM-AVR version : 2.0.8.2 ) _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Thu Dec 05, 2019 3:13 pm Post subject: |
|
|
yes it can be tricky. when i made bascom-8051, most users knew about GWBASIC and it used the PC com port : COM1.
So in order to make it simple, i used the same convention : COM1 for the UART.
For the AVR i used the same method. And the first AVR processors only had 1 UART. And al UART registers did not had any number so the world was simple.
When there came processors with 2 UARTS i used COM2 for the second UART.
Atmel named the second uart with an 1 so there was UDR and UDR1.
Later they renamed to UDR0 and UDR1 using base 0.
So then i used UDR and UDR0 to be equivalent.
But somewhere i goofed up for the SERIALIN/OUT.
The problem is that i can not change it anymore since it would break code. I thought about a switch/option but that will also result in a support nightmare.
So, sorry, this is one of the things i wished i had paid better attention to. _________________ Mark |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Fri Dec 06, 2019 12:26 am Post subject: |
|
|
I think most of the problem is with Atmel. If they had called the Uarts 1,2... etc then most of the problems would have been fixed. But of course they probably think in ASM, like me, where the base address of anything is always 0, and higher addresses in the array are base + 1, base + 2 etc.
I struck this years ago on a unit where we only used 1 Uart originally, so called it Com1. Then we expanded to 2 Uarts, and I decided to assign Com1 = Uart1, Com2 = Uart0. That caused endless confusion later on. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|