News:

;) This forum is the property of Proton software developers

Main Menu

Serial transmit

Started by joesaliba, May 19, 2023, 08:30 PM

Previous topic - Next topic

joesaliba

PIC18F26K22

Previously, I only sent strings through HRSOut.

If I want to send a number, shall I add a modifier? I.e.: -

If I have variable Data with 0x7E, (Decimal 126), and want to send it as hex, do I send it: -

HRSOut Hex Data, or

HRSOut Data ??

Transmission is inverted so cannot check it with a terminal window.

I am ashamed asking this question after 18 years using Positron.

Regards

Joe

trastikata

Hi,

you can use the desired string modifier as per page 212 in the manual i.e.
Dim bData As Byte
HRSOut Hex2 bData

However keep in mind that Data is a protected compiler word and you should rename the variable to something else.

joesaliba

Thank you trastikata.

So I was in the right direction.

Did not know about data that is a protected word as compiler did not complain.

Regards

Joe

John Drew

Quote from: joesaliba on May 21, 2023, 06:39 AMThank you trastikata.

So I was in the right direction.

Did not know about data that is a protected word as compiler did not complain.

Regards

Joe
Hi Joseph,
I think Trastikata was being cautious but bData is a variable and quite different from the protected word DATA.
It's ok to use it but it might lead to a typing mistake later.
Cheers
John

joesaliba


top204

#5
Thanks to Bob, this reply is now in the correct place on the forum. :-)

"Data" is also a protected word in the assembler program, so it will give an assember error if used within the program's listing. It is used in the assembler to store constant data in flash (code) memory.

The compiler uses a seperate, third party, assembler program, so it has no control over its protected words, and I have kept the words used for variables, labels, constants, and procedures in the BASIC listing, in the assembler listing as well, so it is very easy to scan and see what assembler code is produced for a BASIC listing's code sequence, but it does, sometimes, cause problems. However, its advantages outway its few problems. :-)

joesaliba

Quote from: top204 on May 22, 2023, 11:51 AMThanks to Bob, this reply is now in the correct place on the forum. :-)

"Data" is also a protected word in the assembler program, so it will give an assember error if used within the program's listing. It is used in the assembler to store constant data in flash (code) memory.

The compiler uses a seperate, third party, assembler program, so it has no control over its protected words, and I have kept the words used for variables, labels, constants, and procedures in the BASIC listing, in the assembler listing as well, so it is very easy to scan and see what assembler code is produced for a BASIC listing's code sequence, but it does, sometimes, cause problems. However, its advantages outway its few problems. :-)

Thanks Les for the information.

However, it did not produce an error when used with HRSin.

Not at my PC but I thin I used: - Data = Hrsin1.

The only thing I noted that `data' could not be formatted to `Data'.

Regards

Joe

joesaliba

Les,

Using the following compiler does not complain and compiles: -

proc SendB(data as byte)

  if data = 0x21 then
        hrsout1 0x11, 0x23

        elseif data = 0x45 then
            hrsout1 0xA1, 0xA2

        else
            hrsout1 data

    endif

 endproc


trastikata

Quote from: joesaliba on May 24, 2023, 06:22 PMUsing the following compiler does not complain and compiles:

A variable in Procedure gets its name from the Procedure name with conjunction with the declared variable's name.

In your example the actual assembler variable, pertaining to this procedure, will be named SendBdata hence no error.

joesaliba