View previous topic :: View next topic |
Author |
Message |
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Wed Feb 23, 2011 3:04 pm Post subject: Config Print1 support for xmega |
|
|
Should the config print statement for rs485 communication work with xmega's.
When using Config print0 it gives an compiler error, Config print1 compiles, but won't work.;
Code: |
Config Print1 = Portb.0 , Mode = Set
Config Portb.0 = Output
|
Trying it myself with this code;
Code: |
Set Portb.0 ' Set the tx/rx direction
Print "Hello world"
Bitwait Usartc0_status.6 , Set 'wait until TXCIF bit is set
Set Usartc0_status.6 'Clearing the flag by writting 1
Reset Portb.0
|
Will also not work, missing the last 3 bytes because the tx/rx is changed to soon.
Somebody a suggestion, adding a delay is not what i want.
_________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
DToolan
Joined: 14 Aug 2004 Posts: 1384 Location: Dallas / Fort Worth, Texas (USA)
|
Posted: Thu Feb 24, 2011 3:27 am Post subject: |
|
|
Perhaps Usartc0_status.6 was set by some previous print or other anomaly. Start with a known condition first by clearing TXCIF and see if that produces a different result...
Code: | Set Usartc0_status.6 'clear the flag by writing a 1
Set Portb.0 'set the tx/rx direction
Print "Hello world"
Bitwait Usartc0_status.6 , Set 'wait for TXCIF bit to set
Reset Portb.0 |
This also assumes you have no other interrupts enabled / active which might cause "Hello World" to do more important things and let the shift buffer run empty. This would set TXCIF too soon and your Bitwait wouldn't wait as you intend. |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Thu Feb 24, 2011 9:58 am Post subject: |
|
|
Evert,
this should fix it:
Code: | Const USR = USARTC0_STATUS
Config Print = Portb.0 , Mode = Set
Config Portb.0 = Output
Print "Hello world"
|
Btw., makes no difference whether you use Config Print = ... or Config Print0 = ... |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Thu Feb 24, 2011 11:43 am Post subject: |
|
|
@Dtoolan
Your right, it was working fine when cycle the power, but when starting after the bootloader i didn't work, because the bootloader set the status bit.
Clearing the Usartc0_status.6 bit at the top of the main program solved the problem.
You still need to clear the status bit after every tx.
Code: |
Set Usartc0_status.6
Do
Set Portb.0 ' Set the tx/rx direction
Print "Hello world"
Bitwait Usartc0_status.6 , Set 'wait until TXCIF bit is set
Set Usartc0_status.6 'Clearing the flag by writting 1
Reset Portb.0
Wait 1
Loop
|
@Mws
That solved the problem to. Config print is working fine now. _________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Thu Feb 24, 2011 2:14 pm Post subject: |
|
|
Evert,
remains to say that this works only for one serial port.
As well Config Print1 = ... could be compiled, it has no effect.
If you want to use the second uart, it can be done this way:
Code: | Const USR = USARTC1_STATUS
Config Print = Portb.0 , Mode = Set |
Also be aware, that the opcode created by the compiler only clears the flag at exit from Print, means if you use a bootloader which has set the TXCIF flag, then your startup code should clear it, otherwise the first Print won't work as advertised. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Tue Mar 01, 2011 3:41 pm Post subject: |
|
|
it should work fine for xmega first uart.
the other uarts i will add, i see that some special xmega code is missing for them. config print and config print0 are identical. they work for the first uart.
was the problem that flag was not cleared because of the bootloader?
of doesn;t it work completely?
the rs485 code will always clear the flag so a simple solution is to first print one dummy char :
print " "
after it had executed the flag is in the right state. the logic is:
set level
transmit char
wait till transmitted
transmit other chars
change level
from this post it is not exactly clear to me what the problem is/are. _________________ Mark |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Tue Mar 01, 2011 6:49 pm Post subject: |
|
|
Quote: | from this post it is not exactly clear to me what the problem is/are. |
The original problem was the missing definition in the .dat file. |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Tue Mar 01, 2011 8:48 pm Post subject: |
|
|
-The problem with config print was that it gave an compiler error [.EQU not found for:USR].
MWS solved this for me.
-For my own solution in needed first clear the Usartc0_status.TXCIF bit before using it again.
I didn't know that the bootloader had set this bit, so clearing it at the top of the program solved the problem. _________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Tue Mar 01, 2011 8:51 pm Post subject: |
|
|
Evert
which version were/are you using then?
I think all USR aliasses have been added to the xmega dat files.
can you confirm this is still a problem in 2040 ?
Which chip are you using then? _________________ Mark |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Tue Mar 01, 2011 9:15 pm Post subject: |
|
|
Hi Mark,
2040 version with the xm256a3B
With the xm256A3Bdef.dat file dated 6/1/11
Code: |
Config Print0 = Portb.0 , Mode = Set
|
_________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Tue Mar 01, 2011 9:45 pm Post subject: |
|
|
ok, now i found the problem. only printbin was supported, normal print did not use the xmega register. i changed it. _________________ Mark |
|
Back to top |
|
|
|