You are currently viewing How to Interface USB UART with ARM9 Stick Board

How to Interface USB UART with ARM9 Stick Board

Spread the love

ARM9-LPC2929 STICK BOARD

The is specifically designed to help students to master the required skills in the area of embedded systems. The board is designed in such way that all the possible features of the microcontroller will be easily used by the students. The board supports Keil µVision 4 compilers with Keil ULink2.

NXP Microcontroller,ARM9-LPC2929 stick board is proposed to smooth the progress of developing and debugging of various designs encompassing of speed 32-bit Microcontrollers. It integrates CAN, LIN, UART, ADC, PWM, I2C, SPI, Timer, Interrupt etc., to create a stand-alone versatile test platform.

ARM9 Stick Board having more no of I/O line for user access able. Its consists of 64 GPIO pins, CAN0/1, LIN1, I2C0/1, UART0/1, SPI0/1, USB, ADC0/1/2, PWM, Timer and more features. Users can easily access the controller and develop more application by using ARM9 Stick Board.

UART

UART (Universal Asynchronous Receiver Transmitter) are one of the basic interfaces which provide a cost effective simple and reliable communication between one controller to another controller or between a controller and PC.

USB to UART (FTDI Chip)

The FT232R is a USB to serial UART interface device which simplifies USB to serial designs and reduces external component count by fully integrating an external EEPROM, USB termination resistors and an integrated clock circuit which requires no external crystal, into the device. It has been designed to operate efficiently with a USB host controller by using as little as possible of the total USB bandwidth available

Interfacing USB_UART with ARM9 Stick Board

Now we want to display a text in PC from LPC2929 Stick Board by using FTDI USB_UART chip (on board). In LPC2929 Stick Board contains two serial interfaces that are UART0 &UART1. Here we have to select UART0 or UART1 by using the J2 connector (to refer circuit diagram). The Transmitter pins send the data into PC and the receiver pin receives the data from PC.

USB and UART Lines Reference Sheet

JUMBER J2 PinFunctionLPC2929 PinPORT
1UART0/RXD34P1.23
2UART0/TXD35P1.22
3USB/RXD
4USB/TXD
5UART1/RXD130P2.17
6UART1/TXD129P2.16

Circuit Diagram for USB_UART to ARM9 MCU

circuit-diagram-for-usb-uart-to-arm9-mcu

UART Communication settings

1. Open HyperTerminal— Enter the name

open-hyperterminal-for-arm9-stick-board

2. Select the Com Port

select-the-com-port-for-arm9-stick-board

3. Select the Option Restore Defaults

option-restore-defaults-for-arm9-stick-board

4. Then click OK

click-arm9-stick-board--project

5. Output for UART0

arm9-stick-board-output-for-uart0

6. Output for UART1

arm9-stick-board-output-for-uart1

C Program to display a text in PC from ARM9 Stick Board (UART0)

Title :

Program to display a text in PC from ARM9 Stick Board through UART0

/*

LPC2929 Stick Board UART0 Code

Baud Rate : 9600
Crystal : 12Mhz

It Send the string "Hello World!!! ARM9 Stick" to PC

UART0-P1.22 and P1.23

*/

 

#include 

 

#define CLK 12000000

#define BAUD 9600

 

#define DLAB_1 0x80

#define DLAB_0 0x7F

 

unsigned int Fdiv;

unsigned char Str_UART0[] = "Hello World!!! UART0-ARM9 STICK\r\n";

 

void CLOCK_Select(void);

void UART0_Init(void);

void Init_CGU0(void);

void Transmit(unsigned char);

unsigned char Receive(void);

void UART0_puts(unsigned char *);

void DelayMs(unsigned int);

 

int main()

{

CLOCK_Select();

DelayMs(10);

UART0_Init();

DelayMs(10);

while(1)

{

UART0_puts(Str_UART0);

DelayMs(500);

}

}

 

void UART0_Init(void)

{

SFSP1_22 = 1; //UART0 TXD, Config as Digital In w/t int PU

SFSP1_23 = 5; //UART0 RXD, Config as Digital In w/t int PU

 

U0IER = 0x00;

U0FCR = 0;

 

U0LCR = 0x83; //8 bits, no Parity, 1 Stop bit, DLAB = 1

U0FDR = 0x10; //DivAddVal=0, MulVal=1

Fdiv = ((CLK/16)/BAUD);

U0DLM = Fdiv/256; //Baud rate MSB register

U0DLL = Fdiv%256; //Baud rate LSB register

U0LCR = 0x03; //DLAB = 0

}

 

void Transmit(unsigned char Chr)

{

while((U0LSR & 0x20)==0); //Bit5 is used to indicate the status of Transmit buffer

U0THR = Chr; //if it is 1, the U0THR has data

}

 

unsigned char Receive(void)

{

while((U0LSR & 0x01)==0); //Bit0 is used to indicate the status of Receive buffer

return U0RBR; //if it is 1, the U0RBR has data

}

 

void UART0_puts(unsigned char *string)

{

while(*string)

Transmit(*string++);

}

 

void CLOCK_Select(void)

{

SYS_CLK_CONF = 0x01000000; //Direct Crystal Freq = 12Mhz, no PLL

UART_CLK_CONF= 0x01000000; //Direct Crystal Freq = 12Mhz, no PLL

}

 

void DelayMs(unsigned int Ms) //Delay Definition

{

int delay_cnst;

while(Ms>0)

{

Ms--;

for(delay_cnst = 0;delay_cnst<1200;delay_cnst++);

}

}
C Program to display a text in PC from ARM9 Stick Board (UART1)
Title :
Program to display a text in PC from ARM9 Stick Board through UART1
 
/*

LPC2929 Evaluation Board UART1 Code

Baud Rate : 9600

Crystal : 12Mhz

It Send the string "Hello World!!! ARM9 STICK" to PC

*/

 

#include 

 

#define CLK 12000000

#define BAUD 9600

 

#define DLAB_1 0x80

#define DLAB_0 0x7F

 

unsigned int Fdiv;

unsigned char Str_UART1[] = "Hello World!!! UART1-ARM9 STICK\r\n";

 

void CLOCK_Select(void);

void UART1_Init(void);

void Init_CGU0(void);

void Transmit(unsigned char);

unsigned char Receive(void);

void UART1_puts(unsigned char *);

void DelayMs(unsigned int);

 

int main()

{

CLOCK_Select();

DelayMs(10);

UART1_Init();

DelayMs(10);

while(1)

{

UART1_puts(Str_UART1);

DelayMs(500);

}

}

 

void UART1_Init(void)

{

SFSP2_16 = 0x1; //UART1 TXD, Config as Digital In w/t Int PU

SFSP2_17 = 0x1; //UART1 RXD, Config as Digital In w/t Int PU

 

U1IER = 0x00;

U1FCR = 0;

 

U1LCR = 0x83; //8 bits, no Parity, 1 Stop bit, DLAB = 1

U1FDR = 0x10; //DivAddVal=0, MulVal=1

Fdiv = ((CLK/16)/BAUD);

U1DLM = Fdiv/256; //Baud rate MSB register

U1DLL = Fdiv%256; //Baud rate LSB register

 

U1LCR = 0x03; //DLAB = 0

}

 

void Transmit(unsigned char Chr)

{

while((U1LSR & 0x20)==0); //Bit5 is used to indicate the status of Transmit buffer

U1THR = Chr; //if it is 1, the U0THR has data

}

 

unsigned char Receive(void)

{

while((U1LSR & 0x01)==0); //Bit0 is used to indicate the status of Receive buffer

return U1RBR; //if it is 1, the U0RBR has data

}

 

void UART1_puts(unsigned char *string)

{

while(*string)

Transmit(*string++);

}

 

void CLOCK_Select(void)

{

SYS_CLK_CONF = 0x01000000; //Direct Crystal Freq = 12Mhz, no PLL

UART_CLK_CONF = 0x01000000; //Direct Crystal Freq = 12Mhz, no PLL

}

 

void DelayMs(unsigned int Ms) //Delay Definition

{

int delay_cnst;

while(Ms>0)

{

Ms--;

for(delay_cnst = 0;delay_cnst<1200;delay_cnst++);

}

}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.