Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need Uart driver code for Microcontrollers

Status
Not open for further replies.

satish.svap

Newbie level 6
Joined
Sep 11, 2011
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Bangalore, India
Activity points
1,357
Hello,

This my first thread please help me out..

can any one post a complete uart driver code for microcontrollers.

My basic doubt :
Ex: please find the attachment.

In that register if i set bit value 11 then, it will select as a 8 bit character length for the uart transmission. but as soon as you select value 11 how does the controller know it should transmit only 8 characters. should we write a complete code for that or it is inbuilt in the microcontroller.

Please do reply ASAP.

-Thanks
Satish
 

Attachments

  • uart_img.JPG
    uart_img.JPG
    29 KB · Views: 64

What C compiler are you using?

The attachment appears to be from a datasheet for NXP device. What is the exact model of your MCU? What is oscillator configuration/frequency?

BigDog
 

Hey Thanks for ur reply,

I am using keil Cross complier.
Yeah its from NXP, i am using LPC1756 microcontroller.

Oscillator frequency = 12 Mhz.

and i am setting a baud rate of 39473, through DLL & DLM registers.

One more Question:

The on chip peripherals (ADC,UART etc..) in MCU have a inbuilt software?? if So,
Ex: if you want to select 8 bit character length with one stop bit, then these operations are done internally by uart or we have to write code for that in MCU ..



-Thanks
Satish
 

...i am using LPC1756 microcontroller.
Oscillator frequency = 12 Mhz.
and i am setting a baud rate of 39473, through DLL & DLM registers.

Why use a nonstandard BAUD rate? Doing so could make it difficult to establish RS-232 communications with another device.

The on chip peripherals (ADC,UART etc..) in MCU have a inbuilt software?? if So,
Ex: if you want to select 8 bit character length with one stop bit, then these operations are done internally by uart or we have to write code for that in MCU ..

To successfully configure the device's UART you must initialize various registers for the settings that you mentioned above and other additional settings.

You'll need to reference the device's user manual for specific information concerning configuring the UART:



**broken link removed**


Also, check the Keil installation directory for LPC ARM UART examples.


BigDog
 
  • Like
Reactions: FvM

    FvM

    Points: 2
    Helpful Answer Positive Rating
I would like to know answers for these Questions.

In that register if i set bit value 11 then, it will select as a 8 bit character length for the uart transmission. but as soon as you select value 11 how does the controller know it should transmit only 8 characters. should we write a complete code for that or it is inbuilt in the microcontroller.


The on chip peripherals (ADC,UART etc..) in MCU have a inbuilt software?? if So,
Ex: if you want to select 8 bit character length with one stop bit, then these operations are done internally by uart or we have to write code for that in MCU .
 

should we write a complete code for that or it is inbuilt in the microcontroller.

You will need to write a complete UART driver.

The on chip peripherals (ADC,UART etc..) in MCU have a inbuilt software??

No. You will need to write a complete UART driver.

Attached and example LPC17XX UART Example with Driver.
 

Attachments

  • LPC17XXUART.zip
    2.7 KB · Views: 43
  • Like
Reactions: FvM

    FvM

    Points: 2
    Helpful Answer Positive Rating
Thanks !!

int UART0_SendByte (int ucData)
{
while (!(LPC_UART0->LSR & 0x20));
return (LPC_UART0->THR = ucData);
}

while (!(LPC_UART0->LSR & 0x20)); /* this condition should satisfy when the Transmit Hold Register(THR) register should be empty. if not then it will be in infinite loop.

let me make my Question very simple !!
Once the THR has a character to send or when you place a character into THR.
how does ??

1. How does this register gets empty by itself ??
2. suppose it is empty who will raise the flag in FSR that THR is empty ??
3. And how does it exactly send 8/5/4 bit character length if we set in a particular register.. where is that code in the design ??

if it is empty then this code will execute = return (LPC_UART0->THR = ucData);

-Thanks
Satish
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top