tsh 0 Posted March 9, 2013 Share Posted March 9, 2013 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? Quote Link to post Share on other sites
gwdeveloper 275 Posted March 9, 2013 Share Posted March 9, 2013 Have you bothered to look at the Stellarisware examples? UART is available on PA0/1, PB0/1, PC4/5, PC6/7, PD6/7, and PE4/5. Quote Link to post Share on other sites
tsh 0 Posted March 9, 2013 Author Share Posted March 9, 2013 The only example I found in Stelarisware was Uart0. I tried changing all the uart0 for uart1, but obviously missed something... I was kind of dismayed that there was no simple parameter to chose which uart. Quote Link to post Share on other sites
gwdeveloper 275 Posted March 9, 2013 Share Posted March 9, 2013 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. Quote Link to post Share on other sites
tsh 0 Posted March 9, 2013 Author Share Posted March 9, 2013 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. Quote Link to post Share on other sites
gwdeveloper 275 Posted March 9, 2013 Share Posted March 9, 2013 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. Quote Link to post Share on other sites
Terenceang 0 Posted March 9, 2013 Share Posted March 9, 2013 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); tsh 1 Quote Link to post Share on other sites
tsh 0 Posted March 10, 2013 Author Share Posted March 10, 2013 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. Quote Link to post Share on other sites
bluehash 1,581 Posted March 10, 2013 Share Posted March 10, 2013 Hi tsh, You seem to be a beginner in mico-controllers. If you work further into larger and complex projects, the example you posted above may not work out. BUT, looking at what you posted above, you must surely try the Energia Port for the Stellaris. 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.