Page 1 of 1

Printstring to LCD not working ?

Posted: Wed Mar 07, 2012 10:29 pm
by KeesD
Hello,

Printing a string from a stringvariable does not work with the printstring function. The processor is a PIC18F4520.
I am using flowcode 5.1.0.0. PrintASCII and printnumber do work, so the PIC is ok.
It worked with a PIC16F877a.

How can this be fixed, or what am I doing wrong ?

Kind regards,

Kees

Re: Printstring to LCD not working ?

Posted: Wed Mar 07, 2012 10:52 pm
by DavidA
Hi KeesD,

Ill give this a check first thing tomorrow morning.

Re: Printstring to LCD not working ?

Posted: Wed Mar 07, 2012 11:24 pm
by dazz
hi try this one code not very pretty but it works

Re: Printstring to LCD not working ?

Posted: Thu Mar 08, 2012 4:28 pm
by DavidA
Hello KeesD,

We dont have an 18F4520 here, closest i could find was an 18F4523, which worked perfectly.

I would suggest you create a simple program to test it out if you arent doing already.

create a variable "MyStringVar"

LCDStart()

Loop

PrintString(MyStringVar)

Cursor(0,0)

EndLoop

And see if that works with your chip.

Re: Printstring to LCD not working ?

Posted: Thu Mar 08, 2012 10:48 pm
by KeesD
Hello,

thank you for your help.
I tried your program, but it did not work (blank display)
Further I tried the following:
(All variables are created first)

MyStr = "PrintThis"
LCDDisplay Start
LCDDisplay PrintString MyStr
Delay 10s

Result: Blank display. I expect to see "PrintThis" for 10 seconds.

I have done some more tests:

LCDDisplay Start
LCDDisplay Printstring "PrintThis"
Delay 10s

Result: Only one strange character (ascii 0xDC) is printed.

LCDDisplay Start
LCDDisplay PrintASCII "PrintThis"
Delay 10s

Result: This works! The text "PrintThis" is on the display.

So I tried the following:

MyStr = "PrintThis"
i=0 //index
Smb=0 //byte, ascii symbol
LCDDisplay Start
Loop while i<9
Smb = MyStr
LCDDisplay PrintASCII Smb
i=i+1
end loop
Delay 10s

This does not work.

Has it something to do with indexing a string ?

Because it works with PrintASCII I think th Pic is ok.
Also the printnumber and other functions work fine.

Kind regards,

Kees

Re: Printstring to LCD not working ?

Posted: Thu Mar 08, 2012 10:58 pm
by dazz
hi kees forgot to say the one i wrote press one button and it prints one string press the other it prints the second string hth

Re: Printstring to LCD not working ?

Posted: Thu Mar 08, 2012 11:07 pm
by dazz
heres your first one working hth

Re: Printstring to LCD not working ?

Posted: Fri Mar 09, 2012 10:25 am
by JonnyW
Hello.
Has it something to do with indexing a string ?
No, this is pretty fundamental stuff so it should not fail. One thing to point out though is that your variable MyStr is stored in RAM, where as the literal "PrintThis" is in ROM. Could the issue be something to do with your RAM accesses (and could you write a program to test this?).

For example:

Code: Select all

  i = 'a'
  PrintASCII(i)
Should print 'a' onto the screen. Try variants all at once, so:

Code: Select all

  i = 'a'
  PrintASCII(i)
  PrintASCII('b')
  PrintASCII(i + 2)
Should show up as 'abc'

If this only prints 'b', try performing a loop:

Code: Select all

  i = 0
  while i < 5
    PrintASCII('x')
    i = i + 1
  loop
Should print 5 'x' characters. If this does not, then your RAM is almost certainly not working correctly.

I have put some tests in this FCF file, enable one macro at a time and let us know what the results on screen are (and which tests fail) and this may help solve the problem. You may have to set your ports correctly.
multi_lcd_ram_tests.fcf
5 tests of the LCD
(18.05 KiB) Downloaded 292 times
Cheers,

Jonny

Re: Printstring to LCD not working ?

Posted: Fri Mar 09, 2012 10:29 am
by JonnyW
Hello again.

Ben has suggested check your config on the 18F chip for 'Extended CPU', and make sure this is off. This effects RAM accesses apparently (I'm just the messenger!).

Cheers,

Jonny

Re: Printstring to LCD not working ?

Posted: Fri Mar 09, 2012 11:23 am
by KeesD
Hello,

The parameter "Enable extended CPU" was enabled.
I disabled it and everything is working now !
So it had something to do with the internal workings of the chip.

I think I should read the datasheet of the 18F4520 to see what these parameters do and how the memory is organized.

Thanks to everyone who has given an answer to my quetion. It was helpful.

Kind regards,

Kees