Page 1 of 2

SOFTWARE UART - ASM ERRORS

Posted: Mon Feb 01, 2021 9:38 pm
by LEEDNH
I have been running code using the software uart which has worked flawlessly for the past couple of years.
I recompiled and got errors at the asm level. I would very much appreciate any help. Perhaps I could try a copy of SUART V1.4???

After updating to SF VERSION 2.2.3.6 - ICC 1.2.0.7 , the same program
APPEARS TO COMPILE OKAY BUT THE ASM PHASE PUTS UP THE RED FLAG.
GENERATES 3 ERRORS ALL (ASM ERROR):ERROR[113] C:\FILE PATH\name.asm 1067:
Symbol not previously defined (Z) (C) (C)

Device = 18F44k22 'using Vdd = 5.0 v
Clock = 64

' Software UART SET-UP ports tx/rx
SetBaudrate(sbr19200) ' software uart serial data rate is 19200 baud
SetTX(PORTC.4) ' software uart tx port PIN 23
SetRX(PORTC.5) ' software uart rx port PIN 24
SetMode(umInverted) ' software uart serial data is Inverted OR (umTrue)

' ******** READ THE SOFTWARE UART START inverted 19200 8N1 **********
For index = 0 To 115
UART.Read(db)
If index = 16 Then
fix1=db
ElseIf index = 17 Then
fix2=db
ElseIf index > 52 And index < 86 Then
v(index-53) = db
ElseIf index > 109 And index < 114 Then
v(index-106) = db 'v(4) - v(7)
EndIf
Next

Re: SOFTWARE UART - ASM ERRORS

Posted: Tue Feb 02, 2021 5:57 am
by LEEDNH
I think I may have "cried wolf" a bit hastily! I dug out my old computer (on its last legs locks on over-temp) and did not have the error that I mentioned previously. Somehow I must have messed up the installation on the new machine.... I'm a bit embarrassed, one might even say chagrined.....
LEE

Re: SOFTWARE UART - ASM ERRORS

Posted: Tue Feb 02, 2021 10:57 am
by Jerry Messina
I think I may have "cried wolf" a bit hastily!
I don't think you did. Your old PC probably has an older version of the compiler.

The SUART.bas in SF VERSION 2.2.3.6 - ICC 1.2.0.7 will show the error.
I tried to simplify some of the include files and left out some stuff. Sorry!

The attached file should fix it. Unzip and copy SUART.bas to your Library or UserLibrary folder.
NOTE: the file download has been moved to the UserModule Wiki page at https://www.sfcompiler.co.uk/wiki/wiki- ... /SUART.zip

Re: SOFTWARE UART - ASM ERRORS

Posted: Tue Feb 02, 2021 10:23 pm
by LEEDNH
Hi Jerry,
Thank you for your fast response.
The two versions of the compiler that are on the old and new laptops are the latest version - that's what really had me confused...
I loaded up the SUART file and the magic is back!
After my code would no longer compile, I loaded the SUART sample code and it had the same result. Then I thought I would post and inquire.

Back about 3 years, I originally tried to use the standard UART but found the SUART was much easier to implement inside a for-next loop.

Let me just add one final comment... THANK YOU VERY MUCH, JERRY!! (it's one of the most frequent phrases that I see)

Re: SOFTWARE UART - ASM ERRORS

Posted: Sat Mar 13, 2021 4:18 am
by LEEDNH
I am still having problems with the SUART.....THE CODE ASSEMBLES JUST FINE! I USED A COUPLE DIFFERENT SERIAL TERM PGMS REAL TERM SEEMS TO WORK OK, OR AT LEAST BETTER THAN SOME OTHERS GENERALLY.

DUH - THEN I REMEMBERED THAT SF HAS A BUILT IN SERIAL TERM WHICH WORKS BEST.... AS A WAY TO TROUBLE SHOOT THE PROBLEM, i FINALLY LOOPED THE ARRAY BACK TO THE UART WRITE COMMAND AND CAN SUPPLY SOME OF THE I/O AND THE CODE USED.

i INCLUDED THE CONFIG. I THINK I AM RUNNING AT 64MHZ WITH THE 16MHZ RESONATOR X 4...

A LOOK FROM SOMEONE WHO KNOWS WHAT THEY ARE DOING IS APPRECIATED!!!!! i HAVE STARTED TO CLIMB THE WALLS AND MY HEAD IS ACHING FROM COLLISIONS WITH THE CEILING.....

---------------------------------------------------------------------------------------------------------------------------
using SF SERIAL COMMUNICATOR 19200 8N1 USING A USB ADAPTER (LOOPS TO ITSELF FINE)
----------------------------------------------------------------------------------------------------------------------------

test data sent>>>> 1ST TRY: 88 BYTES / 2ND TRY: 176 BYTES (as expected)
LINE #1 TEXT TESTINGLINE #2 abcdefghijklLINE #3 mnopqrstuvwxLINE #4 yz012345678901111111

LINE #1 TEXT TESTINGLINE #2 abcdefghijklLINE #3 mnopqrstuvwxLINE #4 yz012345678901111111

LOOPED THROUGH SUART AS SHOWN BELOW

data received>>>> 1ST TRY:44 BYTES / 2ND TRY 168 BYTES
LN 1TX ETNLN 2acegikLN 3moqsuwLN 4y024680111

LN 1TX ETNLN 2acegikLN 3moqsuwLN 4y024680111LN 1TX ETNLN 2acegikLN 3moqsuwLN 4y02468
!!!LN !DH EDNLN "acegikLN #moacegLN $i
-----------------------------------------------------------------------------------


SOME RELEVANT CODE>>>

Device = 18F14k22 '
Clock = 64 'using 16 MHz x4
Config FOSC = HS 'HS oscillator (high power, >16 MHz)
Config PLLEN = ON

' DIMENSION VARIABLES
'bytes
Dim datrmt(90) As Byte
Dim index As Byte
Dim X As Byte
Dim datval As Byte
Dim db As Byte

'SUART CONFIG ------------------------------------------------------------
SetBaudrate(sbr19200) ' software uart serial data rate is 19200 baud
'SET MODE BEFORE SetTX and SetRX
'SetMode(umInverted) 'software uart serial data is INVERTED at the send end
SetMode(umTrue) 'software uart serial data is TRUE at the send end
SetRX(PORTA.0) ' software uart rx port PIN 19
SetTX(PORTA.1) ' software uart tx port PIN 18



For index = 0 To 87 ' sending 88 bytes

UART.Read(db)
db = db and $7f ' added for trouble shooting
datrmt(index) = db

'If datrmt(0) = datval COMMENTED OUT
'Then GoTo JMPHR1 COMMENTED OUT
'EndIf COMMENTED OUT

UART.Write(db)

Next

Re: SOFTWARE UART - ASM ERRORS

Posted: Sat Mar 13, 2021 12:42 pm
by Jerry Messina
Lee -

Could you post all of the actual code you're using? What you posted doesn't compile as is.

Also, just so you know - in general, software UARTs are usually ok for sending data but have multiple issues reading data.
Since there's no hardware involved, your code must be ready to receive a byte (ie sitting in the UART.ReadByte routine) when the transmitter sends one. Your transmitter has to take this into account and add delays in between sending bytes to allow time for the software UART to process the byte and be ready for the next one.

Doesn't matter too much which terminal program you use (although some are a little more configurable than others). An easy way to test this is to send the string "manually" (ie type it at the keyboard). If it works properly that way but doesn't when you send the entire string then you know you're running into the issue.

This really isn't a PIC or SF issue. You run into the same problem with any chip or language... it's the nature of a software UART.
If you really can't use the hardware USART or live with the limitations, I posted a module on the wiki that's a hybrid of hardware and software Hardware-assisted software uart that works pretty well. It has limits on which pins you can use to receive data since it uses interrupts to detect the RX data START bit.

I haven't tried it on a 14K22, but it should work (famous last words).

Re: SOFTWARE UART - ASM ERRORS

Posted: Sun Mar 14, 2021 12:24 am
by LEEDNH
Hi Jerry
I had a thought about 4 a.m., that I should isolate rx from tx by using a common array but separate FOR-NEXT loops for rx and tx as in half duplex. New code shown below. TNX FOR YOUR SUPPORT!!!!

WORKS GREAT!! I guess it could be called looping data the hard way....

"GET 88 BYTES - NO PIANO INVOLVED ---- SEND 88 BYTES
'-----------------------------------------------------------------------

For index = 0 To 87 ' READ THE 88 CHARACTERS SENT (0-87) FROM RX

UART.Read(db)
lcdrmt(index) = db ' STASH THE 88 BYTES INTO AN ARRAY

Next



For index = 0 To 87 ' 'WRITE TO TX 88 bytes in the array

db = lcdrmt(index)
UART.Write(db) 'send it

Next

Re: SOFTWARE UART - ASM ERRORS

Posted: Sun Mar 14, 2021 7:16 am
by LEEDNH
Jerry
An update on the SUART... After several hours of back and forth at 19200 the version 1.6 SUART works GREAT!!

Downloaded the Hardware-assisted software uart! Placed them in the library - now we do have FULL DUPLEX!

I'll try to use the FDX next weekend...

Best regards
Lee

Re: SOFTWARE UART - ASM ERRORS

Posted: Sun Mar 14, 2021 2:14 pm
by Jerry Messina
Glad you got it figured out.

If you try the FDX module (hwsuart_FD.bas), you'll have to use something other than an 18F14K22.
Full-duplex uses two independent TMRx and CCPx peripherals, one for TX and another for RX, and while the 14K22 has two TMR modules (TMR1/TMR3), it only has a single CCP1 peripheral.

Re: SOFTWARE UART - ASM ERRORS

Posted: Sun Mar 14, 2021 10:35 pm
by LEEDNH
Hi Jerry

I kind of just fell into using the k22 pics (usually the 2xK22) but also the smaller 14K22 when fewer pins are needed.
Thanks very much for the "HEADS UP" as I follow the tried and true engineering maxim regarding the reading of manuals - only after all other options have been exhausted.. Just kidding I saw the 2xK22 test at the start.

Take care
Lee

Re: SOFTWARE UART - ASM ERRORS

Posted: Tue Dec 13, 2022 5:46 am
by LEEDNH
Hello gents!

Just updated the compiler. And my program which uses the SUART Library stopped compiling correctly and gave the following Assembler error:
(Asm Error): [ Error 113] C:path Symbol not previously defined (ONEBT)

So, what I did (after running some previously written code that gave the same error) was to replace the new version with a previous version which is kept in a different directory...

Name : SUART.BAS
* Author : David John Barker
* Notice : Copyright (c) 2006 Mecanique
* : All Rights Reserved
* Date : 2/2/2021
* Version : 1.6 2/2/2021

The aforementioned version of the SUART Library compiles just fine.
Any thoughts?

Regards Lee :) .....

Re: SOFTWARE UART - ASM ERRORS

Posted: Tue Dec 13, 2022 9:32 am
by David Barker
Can you post a small (as small as possible) piece of main program code that generates the error please

Re: SOFTWARE UART - ASM ERRORS

Posted: Wed Dec 14, 2022 12:38 am
by LEEDNH
Surely David

The following line when commented out will allow successful compilation: UART.Read(lrmt(ndx))

Following is the code down to minimum....

Device = 18F14k22 'using Vdd = 5.0 volts
Clock = 64 'using 16 MHz x4 --> PEDAL TO THE METAL

Config
FOSC = HS, // HS oscillator
PLLEN = ON, // Oscillator multiplied by 4
PCLKEN = ON, // Primary clock enabled
FCMEN = OFF, // Fail-Safe Clock Monitor disabled
IESO = OFF, // Oscillator Switchover mode disabled
PWRTEN = OFF, // PWRT disabled
BOREN = SBORDIS, // Brown-out Reset enabled in hardware only (SBOREN is disabled)
BORV = 27, // VBOR set to 2.7 V nominal
WDTEN = OFF, // WDT is controlled by SWDTEN bit of the WDTCON register
WDTPS = 32768, // 1:32768
HFOFST = OFF, // The system clock is held off until the HFINTOSC is stable.
MCLRE = OFF, // RA3 input pin enabled; MCLR disabled
STVREN = ON, // Stack full/underflow will cause Reset
LVP = OFF, // Single-Supply ICSP disabled
BBSIZ = OFF, // 1kW boot block size
XINST = ON, // Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
DEBUG = OFF, // Background debugger disabled, RA0 and RA1 configured as general purpose I/O pins
CP0 = OFF, // Block 0 not code-protected
CP1 = OFF, // Block 1 not code-protected
CPB = OFF, // Boot block not code-protected
CPD = OFF, // Data EEPROM not code-protected
WRT0 = OFF, // Block 0 not write-protected
WRT1 = OFF, // Block 1 not write-protected
WRTC = OFF, // Configuration registers not write-protected
WRTB = OFF, // Boot block not write-protected
WRTD = OFF, // Data EEPROM not write-protected
EBTR0 = OFF, // Block 0 not protected from table reads executed in other blocks
EBTR1 = OFF, // Block 1 not protected from table reads executed in other blocks
EBTRB = OFF // Boot block not protected from table reads executed in other blocks


Include "convert.bas"
Include "utils.bas"
Include "SUART.bas"
Include "system.bas"
Include "setdigitalio.bas"

'bytes
Dim lrmt(88) As Byte
Dim ndx As Byte

'Software UART SET-UP ports tx/rx
'-------------------------------------------------------------------------------
SetBaudrate(sbr19200) ' software uart serial data rate is 19200 baud
SetTX(PORTA.1) ' software uart tx port PIN 18
SetRX(PORTA.3) ' software uart rx port PIN 4
SetMode(umInverted) ' software uart serial data is inverted

' program start----------------------------------------------------------------

For ndx = 0 To 87

UART.Read(lrmt(ndx))

Next

Re: SOFTWARE UART - ASM ERRORS

Posted: Wed Dec 14, 2022 9:23 am
by David Barker
Thanks, I can see that now.

It looks like the routine isn't being linked in correctly.

I can think of a number of fixes but I know Jerry has spent some considerable time on this module so don't want fiddle with his code ;-) I've asked him to take a look.

In the meantime, you can add the following to the SUART module to get it working.

(1) - Click on the module name in the code explorer to open the module
(2) - Double click on the "lock" icon (just above the main code block)
(3) - Add the following to the module:

Code: Select all

//
// initialise module...
//
FTerminator = #13
FPacing = 0
FMode = SUART_DEFAULT_MODE
OneBt() <- *** add this line ***
(4) then click save and close the module

This should get you going for now...

Re: SOFTWARE UART - ASM ERRORS

Posted: Wed Dec 14, 2022 2:06 pm
by Jerry Messina
(Asm Error): [ Error 113] C:path Symbol not previously defined (ONEBT)
Oops!

You'll get that If you use any of the read() functions (read, readbyte, readbytetimeout) without having a write() operation in there somewhere.
The attached should fix it (SUART, v18)