LPC1114: Improved SW UART, 115k @ 12MHz !

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1114: Improved SW UART, 115k @ 12MHz !

2,837 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ArneB on Fri Jan 20 10:10:02 MST 2012
Hi folks,

I needed a SW UART for my application and had a look at the sample provided by NXP... Max 9.6k @ 12 MHz clock frequency ???? Ooops, way too slow for me...

Therefore I have decided to write my own SW UART, optimized for speed. The results are quite surprising: The UART is able to achieve a baudrate of 115.2k at 12 MHz processor clock frequency ! :)
To be honest, I have only tested half-duplex operation (send or receive, but not both at the same time), therefore for full-duplex operation the maximum baudrate will be lower.

I don't claim, that this is the best driver on earth (definitely not...), but it is maybe a good starting point for your current or next project. :D

The attached file is an exported LPCXpresso project, which includes the driver together with a main.c file, which creates a loopback. You will receive every byte you send. It is just a small example, how to use the driver.

Some more implementation details: I have used two different timers, one  for the Tx and the other one for the Rx part. For the Tx part I am using  the external timer match pin (MAT), for the Rx part the capture pin  (CAP).

Any comments or project success stories are welcome !
0 Kudos
Reply
13 Replies

2,773 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ArneB on Thu Feb 09 01:21:44 MST 2012
Outch... :eek:
I have just discovered a nasty bug in the receiver part, which pops up under very specific conditions and corrupts the data. It is corrected now and i have updated the project file in the first post.
Please update the sw_uart.c file from the current archive, if you are already using this driver.
0 Kudos
Reply

2,773 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by js-nxp on Wed Jan 25 12:16:18 MST 2012
Just a quick note to confirm that the new version compiles fine on my computer. :)
0 Kudos
Reply

2,773 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by js-nxp on Tue Jan 24 01:11:59 MST 2012

Quote:
You can use the "lib_small_printf_m0

I have it already in my workspace, unfortunately I have no idea how to use it [COLOR=red]YET[/COLOR]. :p

As I have mentioned before everyone tells me what to do instead of providing me with a all-in-one project like the one you have for the soft uart. :)

Finding my way around it's a little slow even though I have been using micros for more that 30 years particularly when one needs to do real work so one can get paid. No problems with AVR stuff. ;)
0 Kudos
Reply

2,773 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ArneB on Tue Jan 24 00:45:55 MST 2012
*sigh*
@Zero: Thanks again for spotting these absolute paths...
I have removed them and hopefully the project will compile now without any warnings on every computer.

@js-nxp: You can use the "lib_small_printf_m0", which needs <1kByte flash memory. It is located in the LPC111x samples provided by NXP. Just search this forum for "small_printf".
0 Kudos
Reply

2,773 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by js-nxp on Mon Jan 23 14:42:01 MST 2012

Quote:
Just change Include path

Thanks it worked. I had to delete the project a couple of times and start anew until I figured out how to change the path.
[LEFT]sw_uart.bin ; checksum -p LPC1114_301 -d sw_uart.bin;
text data bss dec hex filename[/LEFT]
3428 4 536 3968 f80 sw_uart.axf


But seriously now, this would make a nice additional debug tool for the occasional time when the UART is used and an additonal com port is needed without having to use the nonsensical "console" (sorry!!) by just using one pin and printf.

I understand that due to the size (about 13K it seems) of printf it may not fit in a "small" 32K chip along with the actual user code.
0 Kudos
Reply

2,773 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Jan 23 14:02:29 MST 2012

Quote: ArneB
Ooops, thanks for the hint... :)
I have just modified the project and uploaded it again.




And the last 3 warnings :mad: will disappear if you change your MCU Assembler -> General -> Include paths

from

C:/Projekte/NXP_SECUDIS/Software/Cortex_M0/Archiv/workspace_springfield_test/sw_uart/cmsis

to

../cmsis

also :rolleyes:
0 Kudos
Reply

2,773 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ArneB on Mon Jan 23 13:48:31 MST 2012
Ooops, thanks for the hint... :)
I have just modified the project and uploaded it again.
0 Kudos
Reply

2,773 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Jan 23 13:22:38 MST 2012

Quote: ArneB
I don't have a clue what's going wrong here...
To your other request: I am sorry, but first I have bring peace to mankind, solve the mystery of the bermuda triangle and stop the vogons crushing the earth...:D



Just change Include path from:

C:/Projekte/NXP_SECUDIS/Software/Cortex_M0/Archiv/workspace_springfield_test/sw_uart/cmsis :confused:

to

../cmsis :)
0 Kudos
Reply

2,773 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by js-nxp on Mon Jan 23 13:03:12 MST 2012
I have the CMSIS "project" already open in the default workspace as I simply imported the project into my solitary workspace. :confused:

Quote:
To your other request: I am sorry, but first I have bring peace to mankind, solve the mystery of the bermuda triangle and stop the vogons crushing the earth

I realised how hard it is, by me simply asking for it the forum even crashed yesterday! :(

I have been told ...just do this or that and it will work...but as I thought the good ol' "Hello world" program would be one of the first thing someone would do there would be a ready made example project already out there I could look at.

And of course I mean using printf AND the UART and NOT the "console". So easy but no examples around??
0 Kudos
Reply

2,773 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ArneB on Mon Jan 23 07:32:07 MST 2012
The CMSIS directory is already included in the project file...
0 Kudos
Reply

2,773 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Luis Digital on Mon Jan 23 06:26:04 MST 2012
He may need to import CMSIS.
0 Kudos
Reply

2,773 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ArneB on Mon Jan 23 04:55:12 MST 2012
Hmmm, strange...
I have just created a new workspace, imported the attached project and it compiles fine - in debug and release mode...
The missing "system_LPC11xx.h" file is located in the /cmsis directory. To be honest, I don't have a clue what's going wrong here...

To your other request: I am sorry, but first I have bring peace to mankind, solve the mystery of the bermuda triangle and stop the vogons crushing the earth...:D
0 Kudos
Reply

2,773 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by js-nxp on Fri Jan 20 15:58:26 MST 2012
I have imported the project and it fails to compile.
Quote:

[LEFT]"../startup/cr_startup_lpc11.c"
../startup/cr_startup_lpc11.c:49:28: fatal error: system_LPC11xx.h: No such file or directory[/LEFT]
compilation terminated[SIZE=2].[/SIZE]



oh and while you are there can you please add this into another simple project using stdio and printf\fprintf? :) :p
0 Kudos
Reply