115.2 Kbaud on SuperPRO

Questions on UARTs, and serial communication
Post Reply
basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

115.2 Kbaud on SuperPRO

Post by basicchip »

The SuperPRO (LPC1756), DataLogger (LPC4330), BASICchip (LPC1114) use an internal PCLK of 24 MHz. For generating the baud rate clock at 115.2 Kb this is too coarse and the standard BAUD(x) call needs to be modified.

use --

Code: Select all

#include "LPC17xx.bas"   ' or the appropriate include file 

...

BAUD(1)=125000       ' enable UART1, standard call for 115.2 is too coarse -- needs fractional rate
UART1_FDR = &HC1     ' fractional divider of 1.083333

...

TXD(1) = &H33   ' print an ASCII 3



olzeke51
Posts: 414
Joined: Sat May 17, 2014 4:22 pm
Location: South Carolina

Re: 115.2 Kbaud on SuperPRO

Post by olzeke51 »

Thanks for the update
Gary

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: 115.2 Kbaud on SuperPRO

Post by basicchip »

I did have to add a delay at the end of the BASIC program, because when a BASIC program ends, all interrupts are turned off (except systick and UART0)

To compensate for that, I added a WAIT(1000) at the end of the program.

Code: Select all

#include "LPC17xx.bas"

SUB PrintUART1 (Astr(100) as STRING)
    DIM I as INTEGER
    I=0
    WHILE Astr(I)
        TXD(1) =  Astr(I)
        I=I+1
    LOOP
END SUB
'...

main:

BAUD(1)=125000  ' enable UART1, standard call for 115.2 is too coarse -- needs fractional rate
UART1_FDR = &HC1

for i= 1 to 10
PrintUART1 ("Hello World")       ' Send a string of characters serially out UART1
TXD(1)=13
next

wait(1000)




basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: 115.2 Kbaud on SuperPRO

Post by basicchip »

and now the receive side. I used a USB dongle connected to P2.1 and P2.0

Code: Select all

#include "LPC17xx.bas"

SUB PrintUART1 (Astr(100) as STRING)
    DIM I as INTEGER
    I=0
    WHILE Astr(I)
        TXD(1) =  Astr(I)
        I=I+1
    LOOP
END SUB
'...

main:

BAUD(1)=125000  ' enable UART1, standard call for 115.2 is too coarse -- needs fractional rate
UART1_FDR = &HC1

for i= 1 to 10
PrintUART1 ("Hello World")       ' Send a string of characters serially out UART1
TXD(1)=13
next

' now echo the first 10 charaters sent to UART1

x = 10
while x>0
	y = RXD(1)
	while y = -1
		y = RXD(1)		' when -1 there is no character available
	loop
	TXD(0)=y	        ' echo the character to BASICtools
	x=x-1
loop

Post Reply