View previous topic :: View next topic |
Author |
Message |
richhbd
Joined: 03 Feb 2006 Posts: 52
|
Posted: Sun Feb 26, 2017 7:58 am Post subject: USART issues, 2.0.7.6 vs later |
|
|
Hi all,
I'm recently picking up a project after a long hiatus, and have run into a problem with the most recent builds of the IDE. My project includes three microcontrollers (an M128, which is the master controller, an M8 and an FTDI VNC1L USB host chip). The M8 is connected to UART0 on the M128 and the VNC1L to UART1. The entire project compiles and works fine in Bascom AVR 2.0.7.6 and earlier - but as soon as I upgrade to anything newer (2.0.7.7 all the way to 2.0.8.0) and recompile the M128's code, it wouldn't talk to either of the other micros. Here's an example:
Code: | $regfile = "m128def.dat"
$crystal = 16000000
$hwstack = 64
$swstack = 24
$framesize = 48
Dim R As Byte
Config Com1 = 1500000 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Config Serialin = Buffered , Size = 8
Config Serialout = Buffered , Size = 8
Config Graphlcd = 240 * 128 , Dataport = Porta , Controlport = Portc , Cd = 0 , Rd = 1 , Wr = 2 , Ce = 3 , Reset = 4 , Fs = 5 , Mode = 6
Enable Interrupts 'enable the interrupts
Open "com1:" For Binary As #1 'open the channel to the ATMega8
Wait 1 'allows the M8 to initalise.
Locate 3 , 1
Lcd "sending A0 command"
Locate 5 , 1 'position the cursor
Printbin #1 , &HA0 'tells the M8 to send some data
'check for a response
Do
R = Inkey(#1)
If R > 0 Then Lcd Hex(r)
Loop
Close #1
Stop
|
If I compile and flash the above to the M128 using 2.0.7.6 everything works - the M8 sends back the expected responses to the A8 command. However if I compile exactly the same code with any newer version of the IDE, I get no response from the M8 at all. I've checked the History files and also scanned through the help file and here but I haven't found any hints. Any ideas before I start pulling things further to pieces to check what (if anything) the M8 is receiving? Thanks in advance :-)
(BASCOM-AVR version : 2.0.8.0 , Latest : 2.0.7.8 ) |
|
Back to top |
|
|
P_Santos
Joined: 07 Jul 2011 Posts: 114
|
Posted: Sun Feb 26, 2017 12:11 pm Post subject: |
|
|
Hello richbd,
For year ago i have a similar problem but with Inputbin
and to work i have to add a waitms 3 after If ischarwaiting , so
test it with a little delay in your Do ..Loop
Regards
P_Santos |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sun Feb 26, 2017 1:03 pm Post subject: |
|
|
do you use a boot loader?
the only thing changed for the UART is when calculating the baud, the u2x bit is used when available. see also the history.txt
just compile and check with a terminal emulator if the baud is what you expect. _________________ Mark |
|
Back to top |
|
|
richhbd
Joined: 03 Feb 2006 Posts: 52
|
Posted: Sun Feb 26, 2017 4:59 pm Post subject: |
|
|
Hi both, thanks for the responses. Mark: No bootloader, I use ISP for both the AVRs in this project. The M128 has an externally accessible port while the M8 is socketed so if there is a need to upgrade firmware or troubleshoot I can do so. I did spot the reference to the 2x bit in the 2.0.7.7 history and surmised this was the likeliest contributor but am only now reading up the chip's datasheet to understand the possible consequences. Thank you P_Santos too - I did wonder whether timing is an issue - and prior to posting the example code I tried something similar to your suggestion, and it didn't make any difference to comms with the M8 - but *is* an issue with the live code that communicates with the VNC1L.
What is potentially more confusing is that I have now re-established comms between the M128 and the VNC1L using code that works on both 2.0.8.0 and 2.0.7.6 - but the differences between the two are interesting. I will work up another example and post back in a bit. |
|
Back to top |
|
|
richhbd
Joined: 03 Feb 2006 Posts: 52
|
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sun Feb 26, 2017 9:37 pm Post subject: |
|
|
there is a simpler way : remark the U2X? in the dat file.
this will use the old method of calculating the baud. _________________ Mark |
|
Back to top |
|
|
richhbd
Joined: 03 Feb 2006 Posts: 52
|
Posted: Mon Feb 27, 2017 1:28 am Post subject: |
|
|
Perfect, thanks Mark, that's cracked it. I was wondering if there was a way to do that - I had already explored trying to reset u2x in code.
Now I've got a handle on what the problem was, I can get used to the new features in the IDE and pick the project back up at leisure. Diolch yn fawr, as they say in Wales. |
|
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
|
|