Niral1426459960

Tiva C UART

14 posts in this topic

Hello everyone..

 

I am beginner with Energia. I have Tiva C series launchpad which features TM4C123G series microcontroller. Now this microcontroller has 8 UARTs. I have tested basic serial communication using energia and it works perfectly fine.

 

Now i want to use UART module 3 of this microcontroller which is pin no 13 and 14 (PC6 and PC7). So how can i do this using Energia..??

 

Thank you.

Share this post


Link to post
Share on other sites

It looks like via the code in HardwareSerial.cpp that the constructor for the Serial class is overloaded.

 

HardwareSerial::HardwareSerial(void)

HardwareSerial::HardwareSerial(unsigned long module)

 

If you don't pass a "module", it defaults to 0.  Pass the module that is associated with the configuration you want.  Starting on line 92 looks like all the configurations:

static const unsigned long g_ulUARTConfig[8][2] =
{
    {GPIO_PA0_U0RX, GPIO_PA1_U0TX}, {GPIO_PC4_U1RX, GPIO_PC5_U1TX},
    {GPIO_PD6_U2RX, GPIO_PD7_U2TX}, {GPIO_PC6_U3RX, GPIO_PC7_U3TX},
    {GPIO_PC4_U4RX, GPIO_PC5_U4TX}, {GPIO_PE4_U5RX, GPIO_PE5_U5TX},
    {GPIO_PD4_U6RX, GPIO_PD5_U6TX}, {GPIO_PE0_U7RX, GPIO_PE1_U7TX}
};

...

   //TODO:Add functionality for PinConfigure with variable uartModule
    ROM_GPIOPinConfigure(g_ulUARTConfig[uartModule][0]);
    ROM_GPIOPinConfigure(g_ulUARTConfig[uartModule][1]);

This is a least how it looks like you are supposed to do it.  I've not tried it, but it'd be worth a shot.

Share this post


Link to post
Share on other sites

Hi,

Seems to have a problem with UART3: if this is really what you need then maybe you will be forced to make some modifications/configurations to the library, since up to now there are UART 0, 1, 2, and you need #3.

Look to this thread:

http://forum.stellarisiti.com/topic/1776-stellaris-launchpad-lm4f120-using-uart7/#entry5439

Someone else needed UART7 ...

You may need to use PinMux utility from TI to correctly configure the UART3 pins (write your own and then check/verify with PinMux).

L

Share this post


Link to post
Share on other sites

I think Energia declares all the serial ports so you can just use "Serial3"? E.g. Serial3.begin(115200); and use Serial3.print() et al. Not sure if it sets up to the pins mentioned but you can double check that.

Share this post


Link to post
Share on other sites

I think Energia declares all the serial ports so you can just use "Serial3"? E.g. Serial3.begin(115200); and use Serial3.print() et al. Not sure if it sets up to the pins mentioned but you can double check that.

This is what I did on the stellaris which is more or less the Tiva, worked fine.

Share this post


Link to post
Share on other sites

Reading your reply I am not sure if you got it to work or not. SeralX.xxx will work on both Tiva and Stellaris. 

Did you get it to work on Stellaris and Tiva or are you still seeing issues with this?

Share this post


Link to post
Share on other sites

Reading your reply I am not sure if you got it to work or not. SeralX.xxx will work on both Tiva and Stellaris. 

Did you get it to work on Stellaris and Tiva or are you still seeing issues with this?

I've personally tested Serial, Serial1, Serial3 and Serial7 on the stellaris without issue. Simple sketch that read data from one UART and wrote it to the other (I did it 3 times, Serial on all versions writing to 1 3 or 7). Putty connected to COM5 on windows (being an FTDI cable connected to the stellaris headers for above UARTs) and the energia serial monitor on COM8 for the stellaris. All data typed into putty was received in energia, all data sent from energia was displayed in putty. All testing was at 9600 baud.

 

 

I havent done any testing of i2c or SPI, only used i2c once actually and that was between 2 arduino nano's.

 

 

Rather off topic but I am a huge fan of energia, arduino like environment on the rather powerful stellaris (and in a few days when it arrives the MSP430) is extremely useful. I actually had countless errors with installing code composer studio (I think from university firewall rather than anything else) and dont have a decent enough internet connection at home to install it there, Energia saves the day while allowing me to continue using an environment I am familiar with.

Share this post


Link to post
Share on other sites

Hello guys..

i have compiled successfully with following method.. Where x is module number..

Serialx.begin(9600);
for eg..

Serial2.begin(9600); // for UART module 2
Serial3.begin(9600); // for UART module 3

I have not tested this on hardware.. I will test it on hardware within couple of days..and will post result here..

energia likes this

Share this post


Link to post
Share on other sites

G'day,

I’m in the process of porting over a tested F5529 sketch to Tiva.

Serial1.available() originally worked correctly as my Bluetooth connection, but does nothing now on the Tiva. As the same pins (3&4) and  mother PCB is used, am at a loss. Does appear another Tiva setting is required.

Share this post


Link to post
Share on other sites

As I'm getting nowhere I tried the following LM4FH5QR code (github.com/energia/Energia/issues/165) but it locked up the printout.

   HardwareSerial serial

   HardwareSerial serial1

   void setup(){

       serial.selectModule(1);

      serial.begin(9600);

      serial1.selectModule(2);

      serial2.begin(9600);

…..

}

Is HardwareSerial supported by Tiva?

Share this post


Link to post
Share on other sites
On 1/15/2015 at 6:08 AM, OzGrant said:

G'day

Posted this problem on 43oh and solved by using PC4&5

see http://forum.43oh.com/forum/28-energia/

Grant

Does this mean that the solution to this problem has been posted?  If so, where? 

I am trying to link together four tiva launchpads (TM4C123...) and have them communicate using Serial2, Serial3 and Serial4.  I want to use an array of serials to simplify the code but I cant get the modules selected.  When I try serial[j].selectModule(module[j]); I get the error message "class HardwareSerial has no member named selectModule".  Any ideas?  Thanks,  Jack

Share this post


Link to post
Share on other sites

Be carreful, I recently noticed some differences between TivaC pinout diagram and reality. I did not take the time to push this issue on Github but I will do it as soon as possible.

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