Jump to content
43oh

Simple uart example for Launchpad


Recommended Posts

Very basic question, but I've wasted so much time on this that I have already ordered a Freescale dev board since the Mbed platform looks so much easier to use...

 

All I need is a uart at 9600 baud, on pins other than the ones connected to the debug host so I can connect a bluetooth module.

Wherever people have posted examples, they seem to be of code which doesn't work (asking for help). I just need a working example... I don't really need a whole new framework, but maybe energia is worth downloading, if it's not going to burn up another few hours - but which pins are used for serial there?

Link to post
Share on other sites

It's never that easy. You'll also have to change the pin configuration and the interrupt vector too. If you're looking at uart_echo.c, you can see that it is well commented. I'd recommend using the Stellaris PinMux Utility. Then you can see which peripheral you need and which pins to set up. The utility will show you all the hardware and even generate the setup code for the pins. Next, change the uart's interrupt vector to your specified uart channel.

Link to post
Share on other sites

Energia seems to be able to handle it. (assuming it will build from git) 

 

The comment in uart_echo.c about "viral" open source software really didn't set the right tone to start off with either.

 

If I'm using a MCU dev board, I don't expect to have to spend hours setting up pins unless I want to use some uncommon configuration. I'd rather pay another £20 for better software, and do something more productive with the time. In this space, the MCU is glue logic - or it ought to be. 

Link to post
Share on other sites

Yeah, if all you're looking for is a cut and paste solution, you'll need to look elsewhere. Willing to do some legwork? The examples are good jumping off points. They can't claim full copyright to hardware configuration, they just don't want you using the entire example code as your 'project'.

 

I'm assuming it took hours to learn how to configure the hardware. That should be an expected part of any learning curve. Good luck with the Freescale. Their documentation is tough.

Link to post
Share on other sites

It is actually very simple. I am a few days old to the Stellaris hopes this helps. Matching pins for MSP430LP.

 

 

 

       //
        // Enable GPIO port A which is used for UART0 pins.
        // TODO: change this to whichever GPIO port you are using.
        //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

    //
    // Configure the pin muxing for UART1 functions on port PB0 and PB1.
    // This step is not necessary if your part does not support pin muxing.
    // TODO: change this to select the port/pin you are using.
    //
    ROM_GPIOPinConfigure(GPIO_PB0_U1RX);
    ROM_GPIOPinConfigure(GPIO_PB1_U1TX);

    //
    // Select the alternate (UART) function for these pins.
    // TODO: change this to select the port/pin you are using.
    //
    ROM_GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Initialize the UART for console I/O.
    //
    UARTStdioInitExpClk(1, 38400);
Link to post
Share on other sites

It is actually very simple.

 

Thanks - that was enough to help me realise that the peripheral enable needed changing for GPIOB too. Analogue in next...

 

Obviously I've not tried it yet, but the freescale examples look pretty trivial:

#include "mbed.h"
 
Serial device(p9, p10);  // tx, rx
 
int main() {
    device.baud(19200);
    device.printf("Hello World\n");
}

 

and I need to use 'PTD2, PTD3' rather than 'p9, p10' for the pins. All from one page of the online documentation.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...