View previous topic :: View next topic |
Author |
Message |
kulisek
Joined: 04 Jul 2006 Posts: 51
|
Posted: Wed Jun 11, 2014 1:57 pm Post subject: ATXMEGA USART problem |
|
|
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 |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Wed Jun 11, 2014 3:42 pm Post subject: Re: ATXMEGA USART problem |
|
|
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 |
|
|
kulisek
Joined: 04 Jul 2006 Posts: 51
|
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5921 Location: Holland
|
Posted: Wed Jun 11, 2014 8:58 pm Post subject: |
|
|
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 |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Wed Jun 11, 2014 9:12 pm Post subject: |
|
|
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:
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 |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5921 Location: Holland
|
Posted: Wed Jun 11, 2014 9:18 pm Post subject: |
|
|
MWS seems we wrote at the same time _________________ Mark |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Wed Jun 11, 2014 9:19 pm Post subject: |
|
|
albertsm wrote: | MWS seems we wrote at the same time |
Well, you've made it first to the finishing line |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5921 Location: Holland
|
Posted: Wed Jun 11, 2014 9:26 pm Post subject: |
|
|
maybe because the server is closer at my home _________________ Mark |
|
Back to top |
|
|
|