Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

ATXMEGA USART problem

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
kulisek

Bascom Member



Joined: 04 Jul 2006
Posts: 51

blank.gif
PostPosted: Wed Jun 11, 2014 1:57 pm    Post subject: ATXMEGA USART problem Reply with quote

Hi,

What is wrong on this code: ???

Code:
' **********************************************************
$regfile = "xm32E5def.dat"

$crystal = 32000000

Config Osc = Enabled , 32mhzosc = Enabled

Config Com2 = 1000000 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8    ' <- here is error with Com2 on PC7
Open "com2:" For Binary As #1

' **********************************************************


It gives me error on COM2 USART on port PC6/PC7. COM1 and COM4 is OK

Thanks

(BASCOM-AVR version : 2.0.7.7 )
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Wed Jun 11, 2014 3:42 pm    Post subject: Re: ATXMEGA USART problem Reply with quote

kulisek wrote:
COM1 and COM4 is OK

Surely not, COM1 & COM3 works, COM2 & COM4 won't.
The XMega32E5 provides one UART for PortC and one for PortD, other XMegas provide two UARTs for one port, so enumeration goes there:
PortC_UART0, ...C_UART1: COM1, COM2
PortD_UART0, ...D_UART1: COM3, COM4

For the XM32E5 PortC_UART0 and PortD_UART0 is available, which makes it COM1 and COM3.
Back to top
View user's profile
kulisek

Bascom Member



Joined: 04 Jul 2006
Posts: 51

blank.gif
PostPosted: Wed Jun 11, 2014 4:54 pm    Post subject: Reply with quote

But here http://avrhelp.mcselec.com/index.html?configcomx.htm is written

COM2 - UART_C1 PORTC.7 PORTC.6

and I need PC6/7 for it
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Wed Jun 11, 2014 8:58 pm    Post subject: Reply with quote

it is as MWS says.
if you look in the PDF you will see that RXD and TXD are both on pc2/3 and pc6/7. Some xmega have a remap register where you can remap pins.
for example to remap the UART pins from the default, use PORTC_REMAP.4=1

while this swaps the pins, you still need to access the USART with the correct name.

_________________
Mark
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Wed Jun 11, 2014 9:12 pm    Post subject: Reply with quote

kulisek wrote:
But here http://avrhelp.mcselec.com/index.html?configcomx.htm is written
COM2 - UART_C1 PORTC.7 PORTC.6
and I need PC6/7 for it

Surprise, surprise, the XMega32E5 contains no UART_C1, didn't I write that already?
But - it contains a REMAP-register, where you can decide whether pins 0..3, or 4..7 are used for COM1, it looks that is what you want.
This:
Code:
Set PORTC_REMAP.4

will use PC6 for RXD0 and PC7 for TXD0.
You could have found this out yourself by simply reading the fffriendly manual.
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Wed Jun 11, 2014 9:18 pm    Post subject: Reply with quote

MWS seems we wrote at the same time Very Happy
_________________
Mark
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Wed Jun 11, 2014 9:19 pm    Post subject: Reply with quote

albertsm wrote:
MWS seems we wrote at the same time Very Happy

Well, you've made it first to the finishing line Very Happy
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Wed Jun 11, 2014 9:26 pm    Post subject: Reply with quote

maybe because the server is closer at my home Wink
_________________
Mark
Back to top
View user's profile Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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