Jump to content
Sign in to follow this  
BillBrooks

Help needed with RS232 comms

Recommended Posts

I'm new to microcontrollers and programming, but even newer to the MSP430. I have a Launch pad and a project involving an RFID reader. I have no clue how to receive a serial string and parse them with the 430. I have an Mbed and can do it with that, but its a little expensive for this project. Any advice would be greatly appreciated

 

-Bill

Share this post


Link to post
Share on other sites

Hey Bill,

 

I have a blog which has some beginner guides. More pertinent, I have a post where I explain how to implement a half-duplex software UART. You can use this as a foundation for the rest of your project, once you have the processor receiving data you can start working processing it.

 

http://www.msp430launchpad.com/2010/08/half-duplex-software-uart-on-launchpad.html

 

Hope that helps,

 

NJC

Share this post


Link to post
Share on other sites

Hello,

 

Would the RFID reader happen to be the one from Parallax/Radio Shack? If so, it runs at 2400baud. The LaunchPad can more than handle this.

 

Check Joby's and NJC's posts, they're wonderful.

 

:)

Share this post


Link to post
Share on other sites
Would the RFID reader happen to be the one from Parallax/Radio Shack? If so, it runs at 2400baud. The LaunchPad can more than handle this.

 

I have a couple of those Parallax readers that I haven't done anything with yet. I'd be very interested if you end up sharing your code/project! ;)

 

-Doc

Share this post


Link to post
Share on other sites

I'll be more than happy to share the code. I had the Parallax RFID reader but I killed it somehow. This project will use the RFID 20 from Sparkfun, should be the same code with a higher baud.

 

NJC,

The code posted on your blog looks a little over my head even though I haven't tried to play with it yet. I will probably have a ton of dumb questions!

 

Thanks for the help all!

 

-Bill

Share this post


Link to post
Share on other sites
I'll be more than happy to share the code. I had the Parallax RFID reader but I killed it somehow. This project will use the RFID 20 from Sparkfun, should be the same code with a higher baud.

-Bill

 

Oh, the RFID-20 outputs at 9600 Kbps, just like NJ's uart is set up for. As a quick test, just hookup the RFID-20 to the rx pin of the launchpad (remove the rxd jumper as well), and load NJ's code, and you would get the rfid's tag id echo'd to your computer.

 

Your code should just go into the if received section.

 

 if (hasReceived) // If the device has recieved a value
{
hasReceived = false; // Clear the flag
TXByte = RXByte; // Load the recieved byte into the byte to be transmitted
Transmit();

Share this post


Link to post
Share on other sites
The code posted on your blog looks a little over my head even though I haven't tried to play with it yet. I will probably have a ton of dumb questions!

 

I try my best to break it down nicely. The post I specifically linked to builds off of other posts, so if you feel a bit lost check out the older ones. :-) And about asking questions, there no dumb question (unless its something which can be found using Googles "I'm feeling lucky"). I check out these forums often, and will do my best to explain any parts of my code which might not be clear.

 

Let the questions flow.

 

I'm writing up the last post for the oscilloscope project now, but after that's done I will be making a page with a list of past posts since I know how much of a pain it can be on blogger to go to past posts.

 

NJC

Share this post


Link to post
Share on other sites

Thanks for all the friendly help! Its rare to get that on the internet now.

 

I loaded NJC's code, but cant seem to make it echo anything. I am using a terminal (realterm) and a usb to serial cable through a TTL lever shifter to simulate the RFID reader. My terminal is sending one ASCII character (letter A) at 9600 baud 8N1 but I get nothing back. I confirmed the integrity of what I send with a Saleae logic analyzer and can find nothing wrong. It also seems that that the TX pin goes high after the reset button is pushed and stays high until a logic low is present on the RX pin. :?: I removed the jumpers, what the bleep am I doing wrong?

 

@NJC, thanks for the effort you put into your blog. I'm learning a lot from it, I just need to start from the beginning.

 

@cde, Thanks for the hint about where I should put my code. I kinda thought that would be the place to put it, I just wasn't sure.

 

Thanks for being patient with my noobness!

 

-Bill

Share this post


Link to post
Share on other sites
I loaded NJC's code, but cant seem to make it echo anything. I am using a terminal (realterm) and a usb to serial cable through a TTL lever shifter to simulate the RFID reader. My terminal is sending one ASCII character (letter A) at 9600 baud 8N1 but I get nothing back. I confirmed the integrity of what I send with a Saleae logic analyzer and can find nothing wrong. It also seems that that the TX pin goes high after the reset button is pushed and stays high until a logic low is present on the RX pin. :?: I removed the jumpers, what the bleep am I doing wrong?

 

What you should have is the tx pin of your usb-serial cable connected to the rx(p1.2) of the launchpad, and the rx of your cable connected to the tx (p1.1)of the launchpad. Voltage should not be higher than 3.3v (TTL can be either 5v or 3.3v or 3v).

Finally, handshaking should be off on the terminal. Both jumpers should be off.

 

Question, where you able to get NJ's code working using the launchpad's serial connection?

Share this post


Link to post
Share on other sites
What you should have is the tx pin of your usb-serial cable connected to the rx(p1.2) of the launchpad, and the rx of your cable connected to the tx (p1.1)of the launchpad. Voltage should not be higher than 3.3v (TTL can be either 5v or 3.3v or 3v).

Finally, handshaking should be off on the terminal. Both jumpers should be off.

 

Question, where you able to get NJ's code working using the launchpad's serial connection?

 

I just rechecked my connections, I have my shifter hooked up as you indicate. The shifter I am using is this: http://www.sparkfun.com/commerce/product_info.php?products_id=133 . I just retried the launchpad's comport and am getting nothing as well.

Share this post


Link to post
Share on other sites

I'm not giving up on this. I worked on it until the sun came up and still no luck. The only thing I have found is that when the jumpers are removed and I hook my logic analyzer up to the emulator side of the board I get good serial messages.

Share this post


Link to post
Share on other sites

i think you had too many variables to your problem here.

 

1. is your ttl level shifter reliable at launchpad's logic level?

2. may be typos / timing issues in your source code?

3. pc side serial drivers good?

4. bad cable? (i had replaced the stock launchpad usb cable)

 

i would suggest you go back and start clean w/ basic code that are tried by others.

 

you may want to start by short circuit the launchpad TX RX jumpers. I.e. remove both jumpers and on the emulator side, tied them together. i.e. remove one jumper block and turn the other 90 degrees and short them.

 

you may then use a terminal program on the PC side and type something, it should echo right back. this will at least confirm u are working on good PC side serial driver and your launchpad serial is good (also cable tested).

 

next u may want to get some simple uart examples that others had tried and succeeded, just load and run them. nyc's code or joby's rpn calculator are good examples, (i start uart based programming on this project). if they failed, the authors here and will be easy to get help. if that passes well, u can then work towards modifying them to your needs.

 

anyway it seems that if u have ruled out hardware / pc driver problems, u may need to show us some code to get further help. sometimes it's not apparent, but small typos or swapping event / statement sequences can have big impacts.

Share this post


Link to post
Share on other sites
you may want to start by short circuit the launchpad TX RX jumpers. I.e. remove both jumpers and on the emulator side, tied them together. i.e. remove one jumper block and turn the other 90 degrees and short them.

 

I second this. This has saved me from bad cables and circuit problems. This simple check also verifies your hardware at the lowest level.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×