PC interfacing

Configuring the UART for debugging Stellaris/Tiva launchpads

Both the Stellaris and TIVA launchpads have in-built USB VCP connections which can be used for debugging purposes. When the boards were connected to the PC we can see the COM ports appearing n the Device Manager. The post today will have a quick guide as how to use these to print some debug information. I have used the Stellaris launchpad for the experiment, but the TIVA launchpad also provides a similar interface.

By going through the schematics of the launchpads we can understand how the USB debug connection is made.

1

Here we can see that the UART0 of the IC is connected to the In-Circuit Debugger. UART0 means PA0 and PA1 pins, therefore we need to configure them in order to use this interface.

Following code will configure the UART0 and write a character to the console window.

<pre>	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

	GPIOPinConfigure(GPIO_PA0_U0RX);
	GPIOPinConfigure(GPIO_PA1_U0TX);

	GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

	UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 9600, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

	UARTEnable(UART0_BASE);

        UARTCharPut(UART0_BASE, 'a');

Above code can be used to configure the UART0 interface and put the letter ‘a’ to the terminal window.

In order to make it more debug friendly I have created two functions, one for Init and another to display a string and a hex data value. It is very helpful when debugging firmware. More comprehensive library is available at ‘Stellarisware / Utils /’ directory with the name ‘uartstdio.c’. But it is quite large. This link will have a miniature version of the required components.

Currently I am using it for debugging purposes. Might come in handy to you too. If you come across any issue, put a comment here.

Thank you.

Developing STM32F4-Discovery firmware on Linux (Part 1)

In a world where all the developers are fogged under IDEs this post might sound a bit obsolete. But when it comes to highly demanding embedded applications the Electronics Engineers need unlimited access to hardware. Then we will have to rethink whether the flexibility we required is provided by the “Expensive” IDEs.

This blog post is an aggregation of information I found through following sites. I took time to repost them here to give them wider audience. They are wonderful references.

indexstm32f4_discovery_small

Links:

http://www.wolinlabs.com/blog/linux.stm32.discovery.gcc.html

https://github.com/texane/stlink

http://hackaday.com/2011/10/17/how-to-develop-for-stm32-discovery-boards-using-linux/

I tested the whole system under Ubuntu 14.04 LTS x64 OS. It worked perfectly. Mostly I followed the steps provided by the link 1. But some parts were carried out in a different way. I still did not try any debugging. In this post it will be about compiling and flashing a simple sample firmware.
(more…)

What is libusb?

Hello once again. It has been a while since I updated any thing on the blog. It was not because there is nothing for me to update on the blog, but because I have very less time to work on the blog articles lately. This post, as the topic implies, will consider about one of the trivial technique that Embedded programmers should understand nowadays. That is how to connect the device using USB.

Even though there are millions of standalone embedded devices, there are tens of millions of embedded devices which eventually will come across a state where it should be connected with a PC. There are various ways to perform this, for example using WiFi, Bluetooth, Serial, Parellel, etc.. But among all these technologies most popular and most effective communication method would be through USB. Nowadays there are plethora of devices which implement USB communication.

In order to understand USB, I recommend reading following two websites,

http://www.usbmadesimple.co.uk/

http://www.beyondlogic.org/usbnutshell/usb1.shtml

With that introduction let me move into the area of interest, LibUSB.

500px-USB_Icon.svg_
(more…)