View previous topic :: View next topic |
Author |
Message |
techknight
Joined: 21 Apr 2008 Posts: 231
|
Posted: Thu May 07, 2015 4:15 pm Post subject: RS485 Xmega |
|
|
Finally got my xMega128A1U powered LED driver boards back from the PCB fabhouse from china.
Now, I am in the process of getting the bootloader working.
But for some reason, the RS485 is not transmitting. It worked fine on my old Atmega128 stuff. But not this one.
Here is my UART Setup code. Any ideas?
Code: |
'Configure RS-232 RJ45
Config Com5 = 57600 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8 ' use USART E0,E1,F0
'Configure RS-485
Config Com6 = 57600 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8 ' use USART E0,E1,F0
'Setup for RS-485 Half-Duplex.
Config Print5 = Porte.4 , Mode = Set
Config Porte.4 = Output
Reset Porte.4
'Configure RS-232 RF
Config Com7 = 57600 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8 ' use USART E0,E1,F0
'COM0-USARTC0, COM1-USARTC1, COM2-USARTD0. etc.
Open "Com5:" For Binary As #1
Open "Com6:" For Binary As #2
Open "Com7:" For Binary As #3
|
Thanks.
(BASCOM-AVR version : 2.0.7.8 ) |
|
Back to top |
|
|
techknight
Joined: 21 Apr 2008 Posts: 231
|
Posted: Thu May 07, 2015 4:23 pm Post subject: |
|
|
Nevermind. It works fine..
its just bugs bugs bugs in my bootloader code. |
|
Back to top |
|
|
techknight
Joined: 21 Apr 2008 Posts: 231
|
Posted: Thu May 07, 2015 5:10 pm Post subject: |
|
|
I cant get ischarwaiting working in the main application code though. No matter what I send it, it never acknowledges anything was sent. |
|
Back to top |
|
|
techknight
Joined: 21 Apr 2008 Posts: 231
|
Posted: Thu May 07, 2015 6:02 pm Post subject: |
|
|
I absolutely cannot get UART recieve working in the main application. bootloader is ok.
Here is my UART code:
Code: |
Config Priority = Static , Vector = Application , Lo = Enabled , Med = Enabled , Hi = Enabled 'Init Interrupts
'Configure RS-232 RJ45
Config Com5 = 57600 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8 ' use USART E0,E1,F0
'Configure RS-485
Config Com6 = 57600 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8 ' use USART E0,E1,F0
'Setup for RS-485 Half-Duplex.
Config Print5 = Porte.4 , Mode = Set
Config Porte.4 = Output
Reset Porte.4
'Configure RS-232 RF
Config Com7 = 57600 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8 ' use USART E0,E1,F0
'COM0-USARTC0, COM1-USARTC1, COM2-USARTD0. etc.
Open "COM5:" For Binary As #1
Open "COM6:" For Binary As #2
Open "COM7:" For Binary As #3
'Declare databuffers
Config Serialin4 = Buffered , Size = 254 ' We are using the hardware UART, in buffered interrupt mode.
Config Serialin5 = Buffered , Size = 254 ' We are using the hardware UART, in buffered interrupt mode.
Config Serialin6 = Buffered , Size = 254 ' We are using the hardware UART, in buffered interrupt mode.
Enable Usarte0_rxc , Med
Enable Usarte1_rxc , Med
Enable Usartf0_rxc , Med
Enable Interrupts 'Enable interrupts, buffered UART will operate now.
|
And my mainloop is something like this:
Code: |
Do
If IsCharWaiting(#1) = 1 then
'Do some UART stuffs here
Elseif IsCharWaiting(#2) = 1 then
'Do some UART2 stuffs here
elseif IsCharWaiting(#3) = 1 then
'Do some UART3 stuffs here
end if
'Other non-uart related code here
loop
|
The above works great on everything but my xMega. I tried it both with and without the Enable Usart....... lines. made no difference.
what gives? |
|
Back to top |
|
|
techknight
Joined: 21 Apr 2008 Posts: 231
|
Posted: Thu May 07, 2015 6:44 pm Post subject: |
|
|
I figured it out. Bad programming on my part i think?
I set all my port directions as output prior to declaring the UARTs. Since all my ports primarily are outputs.
But, defining the UARTs dont auto-fix the direction for RXC as regular ATmegas.
So the UARTs didnt work. Removing the direction change for the UART ports, fixed it. |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Fri May 08, 2015 8:01 am Post subject: |
|
|
It usually helps to read the manual
BTW these lines:
Config Com7 = 57600 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8 ' use USART E0,E1,F0
Your spelling of "Asynchroneous" is probably wrong _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
techknight
Joined: 21 Apr 2008 Posts: 231
|
Posted: Sat May 23, 2015 4:21 pm Post subject: |
|
|
lol... RTFM... yea I get it. Who does that anymore?
And I am aware of the spelling error on Asynchronous... However... The compiler will not recognize the word if you spell it correctly. You have to mis-spell it or it will not compile. |
|
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
|
|