anandjm 0 Posted January 25, 2014 Share Posted January 25, 2014 I recently purchased a Cubietruck/Cubieboard3 (http://cubieboard.org/2013/10/30/cubieboard3-cubietruck-is-all-ready/) and since I want to customize the kernels, I needed a USB to TTL Serial converter at 115200bps. Being a weekend I was too lazy to go out to the electronics hardware market, and since I wanted it immediately I did not want to buy it online. So I felt I should be able to use one of my Stellaris Launchpad boards for this purpose. Here is the code for USB to TTL Serial conversion. A better option would be to code directly in "C" with the USB library in Tivaware/Stellarisware, but this code is so simple that I would not waste my time doing it right now. The code should work with any hardware supported by the Wiring framework. -----Code starts here---------- //Red-Blue Combination is most visible for data status indication const int read_LED = RED_LED; //Red LED blinks on data read const int write_LED = BLUE_LED; //Blue LED blinks on data write int read_State=LOW, write_State=LOW; void setup() { pinMode(read_LED, OUTPUT); pinMode(write_LED, OUTPUT); Serial.begin(115200); Serial1.setPins(UART1_PORTB); //Comment if you need to use the alternate port PC4/PC5 Serial1.begin(115200); Serial.println("Simple USB TTL Converter - Stellaris/Tiva Launchpad"); } void loop() { if (Serial.available()){ digitalWrite(write_LED,HIGH); Serial1.write(Serial.read()); } if (Serial1.available()){ digitalWrite(read_LED,HIGH); Serial.write(Serial1.read()); } digitalWrite(write_LED,LOW); digitalWrite(read_LED,LOW); } ------Code Ends here ------- bluehash, energia and Automate 3 Quote Link to post Share on other sites
bluehash 1,581 Posted January 30, 2014 Share Posted January 30, 2014 @@anandjm Thanks for sharing and welcome! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.