This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
HEllo,
Do I need to disable the ICDI to use UART module 0 on tm4c123gh6pm??
Regards,
Vikram
Hello Vikram,
I believe the question is with respect to the EK-TM4C123 LaunchPad. If you need to use the UART-0 the issue is on the RX Side. It is driven by the other MCU which doubles up as the ICDI. What you would need to do is to connect an external debugger and put the switch in device mode. That way you can have access to the UART-0.
Regards
Amit
Hello Amit,
Please have a look at this code. I can't get it to work!!.....I have read this code over and over again and i cant find any problem with it!! I feel perhaps there is a problem with the way am using the launchpad TM4c123gxl.
I am using UART1 on PB0 and PB1 and I am using the groun provided in the booster pack pins.
I have worked on UART before on other chips too!! So, its kinnd of surprising!!.... Is there any other thing to be kept in mind regarding hardware.
I have just connected the pb0 ,pb1, gnd to the respective pins of the com port.
Programmed and powered the chip using ICDI USB.
Here is the code!!
URGENT!!!!
#include <stdint.h>
#include <stdbool.h>
#include<tm4c123gh6pm.h>
#include <hw_memmap.h>
#include <gpio.h>
#include <sysctl.h>
#include <uart.h>
#define Red_LED_DATA (*(unsigned long *)0x40025008)
#define RCGCGPIO (*(unsigned long *)0x400FE608)
#define GPIO_DIR (*(unsigned long *)0x40025400)
#define GPIO_DEN (*(unsigned long *)0x4002551C)
main(void)
{
RCGCGPIO=SYSCTL_RCGC2_GPIOF;
GPIO_DIR=0xFF;
GPIO_DEN=0XFF;
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
// Configure the UART for 115,200, 8-N-1 operation.
UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
while(1)
{
while(UARTCharsAvail(UART1_BASE))
{
if((unsigned char)UARTCharGetNonBlocking(UART1_BASE)=='c')
{Red_LED_DATA=0xFF;}
}
}
}
Hello Vikram,
The line for configuration of the UART-1 Pins is missing
Please add the following
GPIOPinConfigure(GPIO_PB0_U1RX);
GPIOPinConfigure(GPIO_PB1_U1TX);
before the GPIOPinTypeUART line
Regards
Amit
Hello Amit,
The parameters you have used i.e GPIO_PB0_U1RX and GPIO_PB1_U1TX are not being recognized!!
What should do?
Hello Vikram,
Have you put the define PART_TM4C123GH6PM in the pre define section of CCS?
Regards
Amit
Hello Amit ,
I have CCS v6.
No I had not done what you asked!
To put the define I did this:
rightclick on project name->Show Build Settings->C/C++ General->Paths and Symbols
Then under the Symbols tab I added PART_TM4c123gh6PM
It isnt working! even when the error goes away!
Hello Amit,
I have made the proposed changes and i have added the header file pin_map.h which has elimated the error.
Still I cant get the code to work.
I have tried Termite, Docklight and even Putty.
Is there any other thing I might be missing in the code?
Or is it the H/w connections?
Is their anything else ?
What is it I am doing wrong?
Hello Vikram,
How are you connecting the UART TX and RX pins to the PC?
Regards
Amit
Hello Amit,
This is the link to the user manual of ma computer.
At the backpanel of the CPU I dont have a COM port so I had to refer to the manual.
Please see pages 4 and 17 of the manual for the layout of the board and the pinout respectively.
I located the COM Port on the board at the lower left corner where they have labelled COM. Am I right?
http://download.gigabyte.us/FileList/Manual/mb_manual_ga-b85m-d3h_e.pdf
In the Images below I have shown How I have made the connections on the board:
The red wire will be connected to ground of COM port
Orange to the Rx of com port
and black to the tx of com port
I am loading the programing using the ICDI usb only.
I have provided you with all the info i possibly could.
Regards
Vikram
Hello Vikram,
I meant have you wired it from the EK-TM4C123? Just connected the wires to the PC?
Please be aware that while TM4C123 will sustain a 5V signal on the input it would not generate a 5V output for the PC. If you intent to connect it this way then you would need a RS232 driver IC to manage the voltage levels
Regards
Amit
Hello Amit,
I have simply connected the PB0 to Rx of com port of pc, PB1 to the Tx and GND as shown to the grnd of com port
Please read the manual i have provided to verify whether I have used the right port?
What are the o/p level EK-TM4C123GXL will produce for the UART?
So Where should I use the rs232 driver IC?
Hello Vikram,
TM4C devices have high as 3.3V and low as 0V. The voltage can go upto 3.63V on the IO's if you raise the VDDS supply (but that would be working on the extreme end).
My fundamental question is why you want to use UART-1 when UART-0 already connects to the PC via USB?
Regards
Amit
Hello Amit,
I got it working with UART0. However, still a few things I need assistance with!
Well to answer your question!...I want to learn to operate UART with not just the UART0 where I can connect it with a USB but other UARTS too where actual COM port will be used. This is because, later I I professionally work on this MCU, I will not be using the launchpad! :)
Please see this code for UART0:
When I run this code only once the value is being received i.e i can get the LED to switch on but not off
#include <stdint.h>
#include <stdbool.h>
#include<tm4c123gh6pm.h>
#include <hw_memmap.h>
#include<pin_map.h>
#include <gpio.h>
#include <sysctl.h>
#include <uart.h>
#define Red_LED_DATA (*(unsigned long *)0x40025008)
#define RCGCGPIO (*(unsigned long *)0x400FE608)
#define GPIO_DIR (*(unsigned long *)0x40025400)
#define GPIO_DEN (*(unsigned long *)0x4002551C)
main(void)
{
RCGCGPIO=SYSCTL_RCGC2_GPIOF;
GPIO_DIR=0xFF;
GPIO_DEN=0XFF;
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
// Configure the UART for 115,200, 8-N-1 operation.
UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
while(1)
{
while(UARTCharsAvail(UART0_BASE))
{
if((unsigned char)UARTCharGetNonBlocking(UART0_BASE)=='y')
{
Red_LED_DATA=0xFF;
}
else if((unsigned char)UARTCharGetNonBlocking(UART0_BASE)=='n')
{
Red_LED_DATA=0x00;
}
}
}
}
Hello Vikram,
The issue in the code is that when you press 'n' it first reads the data to check for 'y'. Once this data is read from the UARTDR it is lost and hence it does not go into the elseif condition. What you need to do is to read the UART data into a variable and then use the variable for compare operations.
When it comes to using UART's for communicating with PC, you need to be aware of the PC side voltage levels. There is a transciever device 65C3221EPWR which you can go through to see why it is required. There is a lot of history behing UART from voltage perspective, so a good wikipedia read is suggested.
Regards
Amit
Hey Amit,
I got it to work! And I can't imagine I missed that fact!!
Thanks a lot for the info! I will surely look into the tranceiver device.
Regards,
Vikram