| Author |
Message |
|
|
Posted: Nov 28, 2009 - 10:01 PM |
|

Joined: Feb 12, 2005
Posts: 16320
Location: Wormshill, England
|
|
My conclusions:
For xmega UART TX:
The original Atmel loses many characters.
j0n90's cdc.hex loses no characters
Dean's XPLAINBridge.hex loses the odd char.
None are very robust if you fire full bursts at 9600 baud both ways.
However both of the last two options are usable.
I will look at the soft UART code. In my opinion you can get a pretty good two-way soft UART using INT0, COMPA, COMPB interrupts. You receive on the INT0 pin, and TX via the OC2B pin. For example you can echo 115200 baud at full speed without losing a single character. (no other IRQs being serviced)
As an aside. The design of the XPLAIN is for the 1287 UART to provide PDI for the xmega. Surely a regular RS232 bootloader is the simplest arrangement? But I suppose you have no fuse access.
If the 1287 UART was directly connected to any of the xmega's eight uarts, you would have seamless communication. The xmega PDI / JTAG capabilities are already provided by the 10 pin header.
David. |
|
|
| |
|
|
|
|
|
Posted: Nov 28, 2009 - 10:18 PM |
|

Joined: Nov 23, 2009
Posts: 4
|
|
Hi all,
I'm experiencing the same serial problems as everyone here. However, I also have problems programming with Flip. Maybe someone knows the answer how to get the AT90USB chip to boot in DFU mode. The jumper on J200 pin 1+2 does not seem to do the trick.
I noticed that the revision 2 schematic and board layout that are in AVR1902 do not match with the board I received. My board does say A08-0551 Rev 2 though.
As far as I understand Flip, I need to get a different USB product code (USB\VID_03EB&PID_2FFB) when in bootloader mode to communicate with Flip, but I keep getting the virtual COM port (USB\VID_03EB&PID_210D).
Don't have any atmel JTAG programmer. Only the AVRISP mkII.
Once I get this going I'd be happy to test some of the serial stuff. Thanks for any tips. |
|
|
| |
|
|
|
|
|
Posted: Nov 28, 2009 - 10:19 PM |
|

Joined: Jun 10, 2007
Posts: 475
Location: Auckland, NZ
|
|
Man, you guys are amazing would love it if dean could finish up atmels short comings maybe you should sell atmel your code dean hahaha |
|
|
| |
|
|
|
|
|
Posted: Nov 29, 2009 - 03:44 AM |
|


Joined: Jan 23, 2004
Posts: 9830
Location: Trondheim, Norway
|
|
|
Quote:
Man, you guys are amazing Smile would love it if dean could finish up atmels short comings Smile maybe you should sell atmel your code dean hahaha
I wish - I'd love to get some income from LUFA (even though I purposly made it open source and MIT so that more people would use it, to help my job prospects later on) however I don't think Atmel are interested -- after all, they continue to develop their own USB stack.
Quote:
I'm experiencing the same serial problems as everyone here. However, I also have problems programming with Flip. Maybe someone knows the answer how to get the AT90USB chip to boot in DFU mode. The jumper on J200 pin 1+2 does not seem to do the trick.
You need to short the AVR's /HWB pin to GND (I assume that's what that jumper is designed to do) while resetting the AVR. Try shorting the jumper while powering up the board.
I think I remember that some of the boards were supposed to have been released without a DFU bootloader installed on the AT90USB1287; perhaps you were unlucky enough to have received one of those.
Quote:
j0n90's cdc.hex loses no characters
Dean's XPLAINBridge.hex loses the odd char.
Is that loss only in the one direction? The soft UART code is still the same between the two HEX files, as I've simply converted it over to the latest LUFA distribution. The only problem I can see would be characters lost from the XMEGA if the software UART's receive function isn't called fast enough before another character arrives. Normally I buffer the characters directly from the UART receive interrupt, but that's obviously not possible here.
How tight is the timing? Perhaps I'll have a go at implementing the software UART in C using interrupts there so I can buffer the bytes as they are received into the ring buffer.
- Dean  |
_________________ Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
|
| |
|
|
|
|
|
Posted: Nov 29, 2009 - 04:03 AM |
|


Joined: Aug 13, 2006
Posts: 6702
Location: Bellingham, WA - USA
|
|
Not directly related, but I've been having a look at the 1287 DFU bootloader (and the crypto application of the JAVAN kit) to see what they're doing and how the USB stuff works. I've deliberately not looked at LUFA just so when I do get to it I'll have a broader base of experience.
Anyway, I'm amazed that the 1287 DFU bootloader even works at all from some of the things I've seen in there. They write a lot of "reserved" bits and values into various I/O registers (like the PLL divisor), and at one point totally trash RAMPZ and then proceed to use it. I'm sure I'll find more as I continue sniffing around. The Butterfly bootloader likewise had its shortcomings, although nothing quite as gross.
Anyway, they should get Dean to develop a clean version for them. And I'll write up everything I found out in the next couple of weeks. |
_________________ Chuck Baird
"It's better to catch the trapeze than test the safety net" -- RPi book
http://www.cbaird.org
|
| |
|
|
|
|
|
Posted: Nov 29, 2009 - 04:06 AM |
|


Joined: Jan 23, 2004
Posts: 9830
Location: Trondheim, Norway
|
|
|
Quote:
Anyway, they should get Dean to develop a clean version for them. And I'll write up everything I found out in the next couple of weeks.
LUFA already contains my own version of a DFU bootloader, which compiles smaller than Atmel's. I haven't seen Atmel's DFU code because they haven't released the source code to my knowledge; do you have a download link?
For the record, here's the LUFA DFU bootloader source:
http://code.google.com/p/lufa-lib/sourc ... oaderDFU.c
- Dean  |
_________________ Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
|
| |
|
|
|
|
|
Posted: Nov 29, 2009 - 04:08 AM |
|


Joined: Aug 13, 2006
Posts: 6702
Location: Bellingham, WA - USA
|
|
|
Quote:
because they haven't released the source code to my knowledge
The old guys work from the hex files.  |
_________________ Chuck Baird
"It's better to catch the trapeze than test the safety net" -- RPi book
http://www.cbaird.org
|
| |
|
|
|
|
|
Posted: Nov 29, 2009 - 06:40 AM |
|


Joined: Mar 28, 2001
Posts: 20376
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)
|
|
|
Quote:
If the 1287 UART was directly connected to any of the xmega's eight uarts, you would have seamless communication.
It IS directly connected to one of the xmega's eight uarts, USARTC0.
The problem is with the 1287 and the soft usart it uses to communicate with USARTC0. There could also be "issues" with the way USB packets data I suspect but don't really know. |
_________________ John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
|
| |
|
|
|
|
|
Posted: Nov 29, 2009 - 06:43 AM |
|


Joined: Mar 28, 2001
Posts: 20376
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)
|
|
Hey Chuck you should really reveal the number you are holding against your chest in the mugshot.
Or else take another shot with a little smile...you can even assume a sophisticated, debonnaire look if you like...I won't sue you. |
_________________ John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
|
| |
|
|
|
|
|
Posted: Nov 29, 2009 - 07:06 AM |
|


Joined: Aug 13, 2006
Posts: 6702
Location: Bellingham, WA - USA
|
|
Oh, all right. This fuzzy thing will have to do until I go out in the garage and find the one with the tutu on my head.
I rather enjoyed being the grumpy old man. |
_________________ Chuck Baird
"It's better to catch the trapeze than test the safety net" -- RPi book
http://www.cbaird.org
|
| |
|
|
|
|
|
Posted: Nov 29, 2009 - 11:15 AM |
|

Joined: Nov 23, 2009
Posts: 4
|
|
Hi Dean,
Thanks for your answer.
Quote:
You need to short the AVR's /HWB pin to GND (I assume that's what that jumper is designed to do) while resetting the AVR. Try shorting the jumper while powering up the board.
Ok, I found a description of this now. Very confusing that the xplain hardware manual mentions PF4 needs to be shorted to ground instead. Also the HWB pin is not routed and shorting it does not seem to solve it. It just boots with the com port. Guess I'll try an SVF player with a generic JTAG adapter.
Quote:
I think I remember that some of the boards were supposed to have been released without a DFU bootloader installed on the AT90USB1287; perhaps you were unlucky enough to have received one of those.
My board is from Mouser. It looks like the board shown in the "minimizing power" doc8267.pdf. The board layout is different than the schematics in AVR1907. See attached pic.
<rant>
If anyone from Atmel is here: I've never done AVR and this xplain board is not helping much in this way. I've not experienced such a poorly launched dev board in some time. No source code, a manual with mistakes and undocumented boards being sold. I know it is cheap, but something done poorly is worse.
</rant> |
|
|
| |
|
|
|
|
|
Posted: Nov 29, 2009 - 11:55 AM |
|

Joined: Feb 12, 2005
Posts: 16320
Location: Wormshill, England
|
|
Your photo is very different to my XPLAIN board.
Do you have a serial# or any rev# ?
As far as I can remember you will get to the DFU bootloader by putting a jumper over pin #0,#1 of the J200 AT90USB1287 JTAG header. It explains in AVR1907.
David. |
|
|
| |
|
|
|
|
|
Posted: Nov 29, 2009 - 12:02 PM |
|

Joined: Feb 12, 2005
Posts: 16320
Location: Wormshill, England
|
|
I have changed the "uart_soft.S" file in the xplain_cdc LUFA project. This "uart_kbv.c" is an alternative soft UART that copes far better with heavy traffic.
The original design is from danni. It uses the hardware to set the OC2B pin for the TX. This ensues rock solid TX timing.
Code:
#include <avr/io.h>
#include <avr/interrupt.h>
#include "soft_uart.h"
#define BAUD 9600
#define BIT_TIME (uint16_t)((F_CPU + BAUD/2) / BAUD)
#define SRX PD0 // Tiny2313 INT0/INT1 PD2/PD3
#define SRXPIN PIND // Mega32 INT0/INT1 PD2/PD3
#define SRXPORT PORTD // 90USB1287 INT0/INT1 PD0/PD1
#define STX PD1 //PB2
#define STXPORT PORTD
#define STXDDR DDRD
#define W(sfr, x) {sfr ## H = (x) >> 8; sfr ## L = (x);}
#define R(sfr) ((x16 = sfr ## L), x16 += (uint16_t)(sfr ## H) << 8)
#define ADD(dst, src, val) {x16=src##L;x16+=(uint16_t)src##H<<8;x16+=(uint16_t)(val);dst##H=x16>>8;dst##L=x16;}
volatile uint8_t srx_done, stx_count;
volatile uint8_t srx_data, srx_mask, srx_tmp, stx_data;
unsigned char Uart_tx_ready(void)
{
return (stx_count == 0);
}
unsigned char uart_putchar(unsigned char c)
{
while (stx_count);
stx_data = ~c;
stx_count = 10;
return c;
}
unsigned char uart_test_hit(void)
{
return srx_done;
}
unsigned char uart_getchar(void)
{
while (!srx_done);
srx_done = 0;
return srx_data;
}
void uart_init(void)
{
OCR2B = TCNT2 + 1; // force first compare
TCCR2A = (1 << COM2B1) | (1 << COM2B0); // T1 mode 0
TCCR2B = (1 << FOC2B) | (1 << CS21); // CLK/8, T1 mode 0
TIMSK2 = (1 << OCIE2B); // enable tx and wait for start
EICRA = (1 << ISC01); // -ve edge
EIMSK = (1 << INT0); // enable INT0 interrupt
stx_count = 0; // nothing to send
srx_done = 0; // nothing received
STXPORT |= 1 << STX; // TX output
STXDDR |= 1 << STX; // TX output
SRXPORT |= (1 << SRX); // pullup on INT0
}
ISR(INT0_vect) // rx start
{
OCR2A = TCNT2 + (BIT_TIME / 8 * 3 / 2); // scan 1.5 bits after start
srx_tmp = 0; // clear bit storage
srx_mask = 1; // bit mask
TIFR2 = 1 << OCF2A; // clear pending interrupt
if ((!(SRXPIN & (1 << SRX)))) { // still low
TIMSK2 = (1 << OCIE2A) | (1 << OCIE2B); // wait for first bit
EIMSK &= ~(1 << INT0);
}
}
ISR(TIMER2_COMPA_vect)
{
if (srx_mask) {
if (SRXPIN & (1 << SRX))
srx_tmp |= srx_mask;
srx_mask <<= 1;
OCR2A += BIT_TIME / 8; // next bit slice
} else {
srx_done = 1; // mark rx data valid
srx_data = srx_tmp; // store rx data
TIMSK2 = (1 << OCIE2B); // enable tx and wait for start
EIMSK |= (1 << INT0); // enable START irq
EIFR = (1 << INTF0); // clear any pending
}
}
ISR(TIMER2_COMPB_vect) // tx bit
{
OCR2B += BIT_TIME / 8; // next bit slice
if (stx_count) {
if (--stx_count != 9) { // no start bit
if (!(stx_data & 1)) // test inverted data
TCCR2A = (1 << COM2B1) | (1 << COM2B0);
else
TCCR2A = (1 << COM2B1);
stx_data >>= 1; // shift zero in from left
} else {
TCCR2A = (1 << COM2B1); // START bit
}
}
}
|
|
|
| |
|
|
|
|
|
Posted: Nov 29, 2009 - 05:57 PM |
|

Joined: Nov 23, 2009
Posts: 4
|
|
|
david.prentice wrote:
Your photo is very different to my XPLAIN board.
Do you have a serial# or any rev# ?
Yes it has several numbers, but at the back bottom it says: A08-0551 Rev 2.
Note that the pictures is from an Atmel document about measuring power. The shunt resistor on the picture is on my board but not on the schematics.
david.prentice wrote:
As far as I can remember you will get to the DFU bootloader by putting a jumper over pin #0,#1 of the J200 AT90USB1287 JTAG header. It explains in AVR1907.
Yes, but then it still boots with the virtual com port. Not with the jungo interface needed by FLip. |
|
|
| |
|
|
|
|
|
Posted: Nov 29, 2009 - 06:59 PM |
|

Joined: Feb 12, 2005
Posts: 16320
Location: Wormshill, England
|
|
My XPLAIN has several stickers:
A08-0551 Rev A
A09-0560/02
SN0300000265
I am not using Flip at the moment. But surely it will boot into DFU if you Reset the board with pin#0=pin#1. You either cycle the power or bring the Reset pin #6 of J200 to GND.
David. |
|
|
| |
|
|
|
|
|
Posted: Nov 29, 2009 - 09:13 PM |
|


Joined: Mar 28, 2001
Posts: 20376
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)
|
|
You need to install 2 USB driver for the Xplain, 1 for the bridge and 1 for FLIP.
Revision 1 of the board does NOT have a booloader installed in the 1287.
David do you have a finihed hex file for the bridge and the updated soft usart? |
_________________ John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
|
| |
|
|
|
|
|
Posted: Nov 29, 2009 - 10:02 PM |
|

Joined: Nov 23, 2009
Posts: 4
|
|
|
david.prentice wrote:
My XPLAIN has several stickers:
A08-0551 Rev A
A09-0560/02
SN0300000265
Mine are:
A08-0551, Rev 2
A09-0560/04
SN:0200004884
david.prentice wrote:
I am not using Flip at the moment. But surely it will boot into DFU if you Reset the board with pin#0=pin#1. You either cycle the power or bring the Reset pin #6 of J200 to GND.
Thanks for the tip about resetting on pin #6. Booting with pin#0=pin#1 and power cycling does nothing. But with resetting it now works!
With Flip my bootloader version for the AT90USB1287 is 1.F.0. I can't read the flash as it is protected.
Thanks for your help |
|
|
| |
|
|
|
|
|
Posted: Nov 30, 2009 - 12:28 AM |
|


Joined: Jul 02, 2005
Posts: 5946
Location: Melbourne, Australia
|
|
|
yopper wrote:
david.prentice wrote:
My XPLAIN has several stickers:
A08-0551 Rev A
A09-0560/02
SN0300000265
Mine are:
A08-0551, Rev 2
A09-0560/04
SN:0200004884
Mine on the board are:
A08-0551, Rev 2
A09-0560/04
SN:0200000506
... and on the box
A09-0620/04
SN:0200000204
2009.07.17
Obviously the serial numbers have zero correlation with version numbers.
Why on your deity's little earth would anyone issue a "Rev A" and then (or not) a "Rev 2". Is "A" before "2" in any rational sequencing scheme? Sheesh ...
Waiting for the dust to settle before doing anything ...
Cheers,
Ross |
_________________ Ross McKenzie
ValuSoft
Melbourne Australia
|
| |
|
|
|
|
|
Posted: Dec 01, 2009 - 09:54 PM |
|


Joined: Jan 23, 2004
Posts: 9830
Location: Trondheim, Norway
|
|
Attached is a new build of the project, using the above C software UART. Depending on which version has the highest reliability, I'll see if I can use that in the final version of the bridge (once I get permission from all authors).
- Dean  |
_________________ Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
|
| |
|
|
|
|
|
Posted: Dec 01, 2009 - 10:29 PM |
|


Joined: Mar 28, 2001
Posts: 20376
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)
|
|
I put a 25k asm file through the new bridge and could not see any garbage on the screen.
Unfortunately the terminal program cannot send and receive a file as far as I can tell so I saved the screen buffer (uCon terminal, Hyperterminal could not keep up) to a file and then used fc in dos mode. There were differences but I suspect it was just the way screen capture works.
Eye capture looks ok scrolling trough the screen buffer.
If I have some time later on I may try and send some project files and recapture the screen buffer, see if the project still compiles correctly. |
_________________ John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
|
| |
|
|
|
|
|