News:

;) This forum is the property of Proton software developers

Main Menu

Str Issue When Printing

Started by Craig, Nov 20, 2021, 03:07 PM

Previous topic - Next topic

Craig

Hello

I am using a Hitachi 2x16 Display with a Pic18F47k42 Pic and Positron8 Ver.4.0.1.2 What I have seen is that Normal Commands Print Correctly
Ie: Print "Var1= ", Dec Var1 ' Display the decimal value of Var1
but, If I use the Standard Str Modifier then it prints Junk Characters.


________________________________________________________
  Prints Incorrectly in this Format!!
________________________________________________________
  Dim MyArray[10] as Byte    ' Create a 10 element byte array.
  Str MyArray = "HELLO"      ' Load the first 5 bytes of the array
  Print Str MyArray\5        ' Send 5-byte string.

________________________________________________________
  Prints Correctly in this Format
________________________________________________________
  Dim MyArray[10] as Byte    ' Create a 10 element byte array.
  MyArray
  • = "H"             
  MyArray [1] = "E"          ' With the data to send
  MyArray [2] = "L"
  MyArray [3] = "L"
  MyArray [4] = "O"
  Print Str MyArray\5        ' Display a 5-byte string

________________________________________________________

" Cannot understand Why MyArray
  • = "H" Doesn't Display correctly in this Forum Post, won't Edit and display correctly so Please ignore the way it has
been posted it is correct.

Regards
Craig

Yasin

  Dim MyArray[10] as Byte    ' Create a 10 element byte array.
  Str MyArray = "HELLO",0    ' Load the first 5 bytes of the array.
  Print Str MyArray\5        ' Send 5-byte string.

-Does it work if you type it this way? Actually, it shouldn't matter. But page 53 of the manual is self explanatory.

-I don't know exactly why the error is in the forum. But if you put the code samples in code tags, just like I did in this post, the problem goes away.

Best regards

See_Mos

Hi Craig,

It works for me on a 25K22 @ 64MHz.  Try slowing down the LCD write.  This is from my LCD setup

    Declare LCD_DTPin = PORTB.4 ' LCD's Data lines (D4 to D7)
    Declare LCD_RSPin = PORTB.3 ' LCD's RS line
    Declare LCD_ENPin = PORTB.2 ' LCD's EN line
    Declare LCD_Interface = 4          ' 4-bit interface to LCD
    Declare LCD_Lines = 4              ' LCD contains 2 lines
    Declare LCD_DataUs = 50            ' Time to wait after print a data To LCD
    Declare LCD_CommandUs = 2000        ' Time to wait after print a command to LCD
    Declare LCD_Type = Alphanumeric    ' LCD type is alphanumeric
    LATB = 0 : TRISB = $00000011

top204

I've also tried it and it works as expected.

Because you are using an 18F device, you can replace the array with a String variable and everything is taken care of by the compiler. :-)

    Dim MyString As String * 10     ' Create a 10 element String variable
    MyString = "HELLO"              ' Load the string
    Print MyString                  ' Print the contents of the String

The Str and the StrN directives were designed about 17 years ago, when the devices were not suitable for String variables, and they create pseudo String variables from byte arrays. The 18F and enhanced 14-bit core devices have a linear RAM mechanism when used indirectly, which a String does.

The Str and the StrN directives will, eventually, be re-written in the manuals, and removed from main sections, because they are now not actually required in most cases, and only come into their own when sending or receiving byte arrays.

Craig

Hi Yasin and See_Mos Thank you

I tried adding in a Delay and Changing to a different Hitachi Display to see if it made a difference but, Still has the same issue. If I print Normall it works fine but, as soon as I use the STR Modifier it outputs incorrectly.
I think that there is an issue with the STR Modifier in the Positron Compiler, this worked fine in the older Proton Compiler
but, Does not work correctly now. It is possible that there are changes made to the newer version of the Compiler which affect this STR Modifier or something?

The Problem is that I am sending this Via HSerOut [Str sender] to a GSM Modem Where this does make a difference as it is not sending this correctly to the Modem and It Just Prints Garbage Characters on a Standard 2x16 Hitachi type Display, so in both instances it is not working correctly. This is the first time I am using the Pic18F47K42 Device so It could be something that I have not setup correctly? I normally use the Pic18F47K40 which isn't to different.


Dim sender[15] As Byte
Str sender = "1Hello"

Cls
DelayMS 5
Print At 2,1,Str sender," "

'-------------------------------------------------------------------------------------------------
' Assembly code below
'-------------------------------------------------------------------------------------------------
F1_001220 equ $ ; in [CURIOSITY NANO_NOV 2021_18F47K42 TEST 1.BAS] Print At 2,1,Str sender," "
    movlw 128
    movwf BPFH
    movlw 192
    call __lcd_cursor_consts_
    movlw 15
    movwf GEN4
    clrf PP2H
    movlw 40
    call __I2C_SingleBank_StrOut__
    movlw 32
    call __print_

Craig

Thank Very much Les I was typing while See_Mos was Replying and now While you were typing. That makes sense and I will do that.
Thank you for your constant help and excellent advice very much appreciated!
Kind Regards
Craig

Craig

Thank You Les
Just Tested and Works Absolutely Perfectly with both Print and HSerOut.

Regards
Craig