Show Posts
Pages: [1]
1  Using Arduino / Interfacing w/ Software on the Computer / Windows clock drifts while connected to Arduino COM port. on: March 29, 2014, 11:19:53 am
I don't know if this more appropriate in "Setup" forum, or "Interfacing" forum, and it isn't really specific to Arduino, but here goes: 

Many Arduino boards, particularly older revisions, have an FTDI FT232RL chip to provide a USB connection.  The FTDI Windows driver makes this visible on your computer as a virtual com port.  I have discovered that when I have my Arduino 1280 plugged in, and I connect to the virtual COM port with any software (Terminal, PuTTY, BraysTerminal), the clock (time of day) reported by Windows starts drifting.  The same thing occurs with my FTDI cable.  Basically the Windows clock loses 3 seconds per minute, until it's about 6 minutes behind, and then suddenly corrects itself (or something external is correcting it).  Clock drift only occurs when BOTH these conditions are met:
  • Arduino (or separate FTDI cable) is connected to computer's USB port.
  • Software on the computer connects to the associated COM port.

I've Googled every combination of terms I can think of.  My computer was recently wiped & rebuilt (Win7 pro, FTDI VCP driver, and has all updates applied.  Port params: 115200, 8N1.  I do not know if this is new behavior, because until recently I didn't leave the serial port connected long enough to notice.   

I've sent a more detailed report to FTDI support, but I thought I would ask here, since most of you probably have this same combination of chip, driver, and OS.  I would appreciate any pointers or suggestions you can provide.

Thank you,
2  Using Arduino / Programming Questions / Re: How do I detect when TRANSMIT (TX) buffer is full (or empty)? on: March 24, 2013, 12:40:37 pm
Did you actually try it?
It would be useful for HardwareSerial to have a method that does this though.   smiley-red  I thought I had, but I didn't have the extern.  I blame "anti-knowledge" bleeding over from c#.   smiley-roll
and yes

And on another tact I found I should be able to query the interrupt enable flag like this...
bool USART_1_DataRegisterEmptyInterruptEnabled = ((UCSR1B) & (1 << (UDRIE1))) >> (UDRIE1);
...but of course that is specific to serial 1 on the mega1280 family.

I'm not fond of either, because both are prone to breakage if the library changes.  At least I have something better than "well just wait a while". 

Thank you
3  Using Arduino / Programming Questions / Re: How do I detect when TRANSMIT (TX) buffer is full (or empty)? on: March 24, 2013, 11:34:22 am
WizenedEE, your example works great for ring_buffers that I instantiate, but the problem is that there is a private ring_buffer (within HardwareSerial) that I can't access without invasive hacks. 

Lefty, thanks for that.  I was sort of coming to that conclusion, but hoping to be wrong.  It seems a tremendous oversight to not have a way to detect a potential block or overrun.   

Is it possible I could "sense" the empty buffer indirectly by monitoring the enabled state of the TX interrupt?  If so, where is the wiring source that (de)attaches the hardware tx interrupt?  Would be nice to use the same #ifdef logic so my code is portable to other 'duinos. 
4  Using Arduino / Programming Questions / [solved] How do I detect when TRANSMIT (TX) buffer is full (or empty)? on: March 24, 2013, 09:52:49 am
My sketch is sending (not receiving) far more data than will fit into the 64 byte _tx_ring_buffer within HardwareSerial, and the baud rate is slow enough that I'll easily overrun the buffer.  I cannot change the baud rate, modifying the Arduino core to bump up the buffer size is not an option.  

I'd like to know when _tx_ring_buffer is full (and empty) so my app can go do other work, instead of blocking or overrunning.  It seems like such a simple task, but I don't see any public methods, members, or events that tell me the state of the TX buffer.  There is lots of methods for checking available data, contents, etc of the RX buffer, but none that I can find for the TX buffer.  Surely I'm overlooking something.    

Right now my kludge work-around is to shove 64 bytes into the buffer and then sleep the current thread (technically letting other threads do their thing) for an estimated time for HardwareSerial to pump the TX buffer dry at the given baud rate.  Repeat until all data is transmitted.

So, how do I detect when the TX buffer is full (or empty)?

Any help would be appreciated.
5  Using Arduino / Microcontrollers / Re: Mega1280 versus Mega2560 (I received wrong product) on: October 20, 2012, 01:44:35 pm
Acutally, it turns out that debugging on the 1280 (unlike the 328) requires JTAG, not debugwire.  *sigh* 
6  Using Arduino / Microcontrollers / Re: Mega1280 versus Mega2560 (I received wrong product) on: October 20, 2012, 12:30:35 pm
Thanks for the quick reply.  What about debugging?  I believe that I have to cut the RESET-EN trace to use debugwire on the Mega (1280).  Is the same true of the 2560 variations?
7  Using Arduino / Microcontrollers / Mega1280 versus Mega2560 (I received wrong product) on: October 20, 2012, 11:41:21 am
Yesterday in a retail store I purchased an Arduino Mega 2560.  This morning I discovered that the packaging actually contains an Arduino Mega (1280).  I don't actually need the extra flash, and it's a long drive to exchange/return this thing, so I'm wondering ....

What known issues are there with the Arduino 1280 that are fixed in the Arduino 2560 (R3)?

8  Using Arduino / Microcontrollers / Re: Need help with JTAG debugging on Leonardo on: October 18, 2012, 08:37:58 pm
Very close.  As I understand it you wouldn't be able to debug with an ISP, but--yes--just knowing that you had successfully used a JTAG debugger to single step code on a Leonardo would be a nice, first, baby step.  Knowing that someone succeeded specifically with the JTAGICE3 and the Olimex Leonardo would be awesome; as would knowing exactly how they adapted the JTAG header to the Leo.  That may sound trivial to the point of being silly, but try to understand where I'm coming from.  I've spent 4-5 days trying to figure this out, with zero luck.  So, I'm taking it one tiny step at a time.  Since debugging a Leonardo requires different hardware and pinout than an Uno, I expected to see some details about it in the list of how Leonardo differs, or in a tutorial, or forum post, or ... something.  I can find nothing of the sort.  So I pieced together knowledge from 3 datasheets to make an adapter that I think is right.  Seems strange to me such an adapter isn't already widely commoditized by now, but whatever.  It would be nice if someone could validate my stripboard design (design and photos are attached above), or point me to another design I could use for reference.  It would also be nice to know whether I have the fuses and project settings correct.  If all those things are correct, then maybe I have a problem with my JTAGICE3, but I can't make that leap without a little help validating the other stuff first.  So that's what I'm asking for.  
9  Using Arduino / Microcontrollers / Re: Need help with JTAG debugging on Leonardo on: October 18, 2012, 03:20:50 pm

I cannot possibly be the first person to try JTAG on a Leonardo. 
10  Using Arduino / Microcontrollers / Need help with JTAG debugging on Leonardo on: October 15, 2012, 10:26:18 pm
Unrelated to my other post, I would like some help with JTAG debugging of a Leonardo.

First, I had to build a JTAG adapter for the Leonardo.  After reading the datasheet for the Atmega32u4, the Olimexino32u4 (Leonardo clone), and the JTAGICE3, I assembled a stripboard adapter as shown in the attachments.  I think I did it right, because I can read and re-program the Arduino with no problems.  However, all attempts to start a debug session are failing.  Can someone help me with this?

I have the JTAGEN fuse programmed, and am uploading a simple blink program.  When I press <alt><f5> (start debugging and break), the chip gets programmed, followed by a 5-10 second pause, followed by an error message.  At that point the blink program begins running as it should (I can program different durations to verify that programming is working).  The output window of AS6 contains only this: 
21:21:03: [ERROR] , ModuleName: TCF (TCF command: Processes:getContext failed.)
21:21:03: [ERROR] Failed to start debugging session., ModuleName: TCF (TCF command: Processes:launch failed.)

11  Using Arduino / Installation & Troubleshooting / Re: Leonardo uploads and runs, but no Serial (USB) output on: October 13, 2012, 11:47:58 pm
I'm drowning here, guys.  Should I have posted this somewhere else?   

12  Using Arduino / Installation & Troubleshooting / Leonardo uploads and runs, but no Serial (USB) output on: October 13, 2012, 10:52:21 am
I've read the troubleshooting guide, and searched for similar issues.  Nothing quite matches my issue. 

I can upload and run sketches, and my Leonardo USB enumerates to a COM port that I can connect to, but I can't get any serial output from that Leonardo COM port. 

  • Blink uploads and runs fine.
  • (Hardware) Serial1 (pins 0 and 1) works fine to my FTDI cable (shows up as COM4 on my system).
  • Leonardo enumerates to COM6 when plugged in or reset. 
  • The Leonardo has nothing plugged into it except the USB cable and ISP programmer. 
  • The programmer is genuine Atmel JTAGICE3 and it's clearly working (Blink uploads and runs).
  • I use Atmel Studio 6 for development (clearly working with this board and my other Arduino variants).
  • Unplugging the programmer and resetting the Leo doesn't help.
  • Device Manager (Windows 7 64) indicates the Leonardo com port/driver is working fine.
  • I got the Leonardo driver from the Arduino 1.0.1 distribution.
  • I can see and connect to either of the above listed COM ports in my terminal software (Brays Terminal v1.9b).
  • Terminal shows expected output from COM4 (FTDI / Serial1), but nothing when connected to COM6.
  • I figured out that the loopback test can't work on the Leonardo variant, but I don't see that documented anywhere.
  • The Arduino itself is an Olimex Olimexino32u4 (Leonardo clone).
What am I overlooking? 

Here's my test code:
#include <Arduino.h>

int led = 9;

void setup() {
pinMode(led, OUTPUT);
Serial.begin(9600); //speed is apparently irrelevant

void loop() {
digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
delay(1000);               // wait for a second
digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
delay(1000);               // wait for a second
Serial.println("test");      //doesn't work (Leonardo USB)
Serial1.println("test2");   //works great (pin 0, 1)
Pages: [1]