SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By the_julle
#194862
Hi All.

I'm using a Pro Micro with the ATmega32U4 (5V, 16MHz) microprocessor and built-in USB programmer.

This is the one I have:
http://cgi.ebay.co.uk/ws/eBayISAPI.dll? ... 2374507509

which is a clone of:
https://www.sparkfun.com/products/12640


QUESTION 1
I have tested with two setups:

1) Windows driver (in Windows device manager) is using Arduino Leonardo driver. IDE is compiling code for Arduino Leonardo board. This is the default plug-and-plug and works out of the box.
2) Windows driver is updated to use SparkFun Pro Micro driver. IDE is compiling code for SparkFun Pro Micro 5V board. This is the recommend setup (I guess) according to this guide: https://learn.sparkfun.com/tutorials/pr ... okup-guide

Both of these methods are working for a simple serial example with a flasing LED
I am not sure why I should not just use the Leonarder programmer? Why install the additional drivers?


QUESTION 2
I cannot get a correct data flow when using Serial1. This is my simple sample code, where I am testing both Serial write and print.
However, My data is looking like below. Seems like my encoding is not correct? My baud rate is correct. What can be the issue? I have tested with 2 very different rs232 to usb. I connect TX -> RX and RX -> TX as well as a common GND.
Image
Code: Select all
void setup()
{
	Serial1.begin(9600);
}

void loop() 
{
	Serial1.write("A");
	Serial1.flush();
	
	Serial1.write(10);
	Serial1.flush();

	Serial1.print("A");
	Serial1.flush();

	Serial1.print(10);
	Serial1.flush();

	Serial1.println("A");
	Serial1.flush();

	Serial1.println(10);
	Serial1.flush();

	delay(1000);
}
By Valen
#194892
Since you are using a 'clone' it is risky to assume the Sparkfun tutorial applies to the board that you have. The exterior of it might look the same. But who knows which bootloader the cloners put into it. Or which parts they adjusted for the sake of costs.

Can you also configure Putty to show the data in hexadecimal format?
If you connect D0 to D1 (hardware RX to TX) then it should read what it is transmitting itself. If you then can send that from "Serial1" to "Serial" (the USB virtual serial port) then it should show up in serial monitor. Does that return the same data?

Do you have any way of analysing the signal shape? Oscilloscope perhaps? That should immediately identify if the bits are falling over or if the timing is incorrect.
By the_julle
#194897
Thank you for your reply. I have now done further testing.

I have tested the signal using a scope, see the attached screenshot. I'm not sure what to exactly look for? :-) However, I have tested the same code with the original Arduino Mega, and it seems to be the same signal. Also, when using Putty to read the signal from the Mega, I get the same weird looking text.

This is the data received in PuTTY, where PuTTy logs the data to a HEX file:
0D 0A BD E9 00 BD E9 00 BD E9 00 BD E9 00 BD E9 00 BD

So it could seem like the clone Pro Micro is working as expected, and it is something in my setup??

I have two different USB-RS232:
One expensive MOXA, where I have recorded the HEX data using PuTTy.
One cheap from Ebay. Same result.

I connect GND (pin 5) to GND on the board.
I connect RX (pin 2) to TX on the board.
I connect TX (pin 3) to RX on the board.

And make sure, that PuTTY has the same baud rate as in my code. Not really sure what could got wrong....
You do not have the required permissions to view the files attached to this post.
By the_julle
#194898
And the recorded data, from a MEGA.
You do not have the required permissions to view the files attached to this post.
By the_julle
#194899
Aha, I think I finally found the issue here.....

I don't have a RS232 to TTL converter, which means my USB-RS232 is not getting correct input data :-) Next step is to try i loop-back, so sending from Serial1 to Serial0 as that should work.
By the_julle
#194900
Yep, that must be the issue.

I have made this code on the Mega:
Code: Select all
void setup() {
	Serial.begin(9600);
	Serial1.begin(9600);
	Serial3.begin(9600);
}

void loop() {
	
	Serial3.print("A");
	
	if (Serial1.available()) {
		int inByte = Serial1.read();
		Serial.write(inByte);
	}

	if (Serial.available()) {
		int inByte = Serial.read();
		Serial1.write(inByte);
	}

	delay(100);
}
And then placed a wire from TX3 to RX1, which means I can read the data from the Serial0 port on Windows.


So, only 1 question left:
Let's say I have the SparkFun Pro Micro with the ATmega32U4 (5V, 16MHz). Why should I use the SparkFun drivers instead of the Leonardo?
By Valen
#194905
the_julle wrote:Aha, I think I finally found the issue here.....

I don't have a RS232 to TTL converter, which means my USB-RS232 is not getting correct input data :-) Next step is to try i loop-back, so sending from Serial1 to Serial0 as that should work.
That would make sense. RS232 has the opposite polarity (and bigger voltage swings) than TTL serial. A 0-bit in RS232 is positive, a 1 bit a negative voltage. Wheras TTL treats 0 volt as a 0-bit and positive 3.3/5 volt as 1. So none of what you showed could be interpreted as an "A" and the other values probably are non-displayable characters.

I don't know the specifics about the Sparkfun driver, nor the Leonardo. But I remember Sparkfun issueing it to fix people getting warnings because the then current drivers were unsigned. Windows 8 and 10 make (made) a big fuss about that.
https://www.sparkfun.com/news/1918

But it seems that driverpack mentioned in the guide is also intended to teach the Arduino IDE how to use all or most of Sparkfun's boards. So you don't have to guess(timate) what it is compatible to. If you want details about it then I think you better ask techsupport directly. They don't always read the forum.