Prop2 V8 questions re testing
Cluso99
Posts: 18,071
I have successfully loaded the base code into my DE-Nano and compiled/downloaded pasm code with pnut to flash my external rgb leds.
How are you guys testing the serial?
I have been compiling and loading with pnut v8 using F11, then running PST to see the serial output.
But I am not seeing anything being output so I am unsure what is happening. Here is my code in case there is a bug that I cannot see. Its a mix of Chip & Ozprop's code with a bit of mine thrown in.
How are you guys testing the serial?
I have been compiling and loading with pnut v8 using F11, then running PST to see the serial output.
But I am not seeing anything being output so I am unsure what is happening. Here is my code in case there is a bug that I cannot see. Its a mix of Chip & Ozprop's code with a bit of mine thrown in.
CON
_xinfreq_ = 80_000_000
_SIpin = 63 ' \ usual serial input pin (from TXD on pc)
_SOpin = 62 ' | output pin (to RXD on pc)
' _SIOmode = 0 ' | usual mode
_SIObaud = 115200 ' / common baud (serial speed)
' _SIOpins = _SIOmode << 16 | _SIpin << 8 | _SOpin
_SIObits = 8 ' 8-bit char
nco_baud = round(float($1_0000) / (float(_xinfreq_) / float(_SIObaud)))
dat org
' pinsetm pm_tx, #_SOpin 'set asynchronous tx mode in smart pin 0
' pinsetx bitper, #_SOpin 'set tx bit period
pinsetm #%1_11110_0,#_SOpin
pinsetx ##$8000_0000 | nco_baud << 16 | %1_00000 | _SIObits-1,#_SOpin
setb dirb,#_SOpin 'set tx to output
cloop call send_char
add tx_char, #1 ' char++
and tx_char, #$3F
waitx #500
jmp #cloop
send_char pingetz temp, #_SOpin wc 'wait if busy
if_c jmp #send_char
pinsety tx_char,#_SOpin
ret wz,wc
pm_tx long %0000_0000_000_0000000000000_01_11110_0 'async tx mode, output enabled for smart output
bitper long (_xinfreq_/_SIObaud)<<16 + (_SIObits - 1) ' clocks/bit, 8-bit char
x long 0
y long 0
temp long 0
tx_char long $30

Comments
Totally forgot.
However, I cannot get anything to output correctly using async uart with tx on P0 on De0-nano.
Here are two versions I have tried
CON _xinfreq_ = 80_000_000 _txuart = 0 ' P0 _SIObits = 8 ' 8-bit char _SIObaud = 115200 ' baud (serial speed) nco_baud = round(float($1_0000) / (float(_xinfreq_) / float(_SIObaud))) dat org pinsetm ##%0000_0000_000_0000000000000_01_11110_0,#_txuart pinsetx ##$8000_0000 | nco_baud << 16 | %1_00000 | _SIObits-1,#_txuart setb dira,#_txuart cloop call send_char add tx_char, #1 ' char++ (limits $30-$3F) and tx_char, #$3F ' waitx delay jmp #cloop send_char pingetz tmp, #_txuart wc if_c jmp #send_char ' wait if busy pinsety tx_char,#_txuart ret wz,wc tmp long 0 tx_char long $30 delay long _xinfreq_and I have tried both with inversions.Does anyone have working P0 TX UART code working on De-Nano at 115,200 baud to a PC via propplug or equivalent???
I don't what else might be wrong, but the formula for computing the 16-bit NCO baud is:
$1_0000 * (baudrate/clkrate)
For 115.2kb at 80MHz clock, it would be:
$1_0000 * (115_200/80_000_000) = 94
You'd use: '$8000 + 94' for the baud field.
That's right.
I just added the NCO baudrate formula into the Google doc.
Chip,
Do the De0-nano smart pins wrap from 0 to 63 for the pin -1/-2/-3 options ???
I am thinking this way could use P0 & P1 smart pins with actual P62 & P63 pins. Just trying to get the serial back to the programming propplug pins.
Fixed a couple of bugs pointed out above. Thanks for your help.
Then removed a serial 1K resistor - I am using a CP2102 USB/serial which is operating at 5V.
Both NCO & Counter Mode work.
'' RR20160416 working :) CON _xinfreq_ = 80_000_000 _txuart = 0 ' P0 _SIObits = 8 ' 8-bit char _SIObaud = 115200 ' baud (serial speed) nco_baud = $1_0000 * (_SIObaud / _xinfreq_) '=94 dat org pinsetm ##%0000_0000_000_0000000000000_01_11110_0,#_txuart ' pinsetx ##(($8000 + 94) << 16) + 7, #_txuart pinsetx ##(80_000_000 / 115_200)<< 16 +7,#_txuart setb dira,#_txuart send_char pingetz tmp, #_txuart wc if_c jmp #send_char ' wait if busy pinsety #$37, #_txuart jmp #send_char tmp long 0Now to try redirecting to P62
PINSETM ##%0110_0000_000_0000000000000_01_11110_0,#_txuart ' P0-2=P62
Is the above supposed to redirect the output to pin - 2 in Async Transmit ???
It still outputs on P0, not on P62. Am I understanding the smart pins correctly, or does it only work for inputs ???