LCD won't play right

MrDEB

Well-Known Member
seems I have been here before. I ordered some crystals but what gets me is I had this operational before.
Same circuit but uing a 4520. Now have a 18f4321. Have two LCDs that only show white squares but different patterns.
I think it's a timing issue but?
here is my code (sorry forgot how to correctly post code)

Device=18f4321
Clock = 8 '8MHz
Config OSC = INTIO2
#option LCD_DATA = PORTD.4
#option LCD_RS = PORTD.1
#option LCD_EN = PORTD.0
#option SWORDFISH_SE = true
Include "IntOSC.bas"
Include "SetDigitalIO.bas"
Include "Utils.bas"
Include "LCD.bas"

// some LCD options...

// set this option true if building with the SE compiler

// program start...
While true
SetAllDigital
Cls
WriteAt(1,1,"Hello World")
Wend

Member
Disclaimer - I know nothing about Swordfish, I don't own a PIC18F4321 and I have no idea what LCD display you are using...

This line bothers me...
Code:
#option LCD_DATA = PORTD.4
In my experience, LCD data port is 4 bits wide, or 8 bits.
PORTD.4 implies a single bit definition in my head
Should this be...
Code:
#option LCD_DATA = PORTD
Just guessing...

MrDEB

Well-Known Member
the LCD can be run in 4 or 8 bit mode. If using 4 bit the portD.4 inducates that the last port bits are used for data.
this is a Hitachi HD44780

Dan Soze

Member
Disclaimer - I know nothing about Swordfish, I don't own a PIC18F4321 and I have no idea what LCD display you are using...
From page 46 of Swordfish Compiler Language Reference Guide:
============================================================
Code:
#option
#option identifier [= expression]
Creates an option identifier. An option identifier is global and identical to the #define directive in every way, except for two main differences. Firstly, an option identifier can be seen and used in the declaration block of a user program. For example,
Code:
#option BUFFER_SIZE = 64
const MyBufferSize = BUFFER_SIZE
In the above example, the program constant MyBufferSize becomes equal to 64, as this is the value assigned to the option identifier BUFFER_SIZE. It is important to note that a user program identifier will always take precedence over an option directive. For example,
Code:
#option BUFFER_SIZE = 64
const BUFFER_SIZE = 16
const MyBufferSize = BUFFER_SIZE
In this example, MyBufferSizebecomes equal to 16. The other difference between option and define directives is that re-declaring an option twice, using the same identifie,r will not cause an error. For example,
Code:
#option BUFFER_SIZE = 64
#option BUFFER_SIZE = 16
In this example, BUFFER_SIZE will become equal to 64, which is the first option found by the preprocessor. The second declaration of BUFFER_SIZE is ignored.

This capability may appear a little redundant at first, but it's an extremely useful technique to enable users to configure a module from their main program code.

============================================================

In my opinion the Swordfish Compiler directive "#option" seems to be a method to inject syntax bugs in a way the compiler will not find.

This issue seems to concern the developers as the next directive described on page 47 is "IsOption(Identifier)".

This directive is used to validate that a symbol declared using the #option directive is a member of a valid list of options.

The syntax of the example in the Reference Guide on page 47 is wrong, it is missing the #else part.

The correct example should be something like:
Code:
#if IsOption(USART_LS) and not(USART_LS in(true, false))
#error USART_LS, "Invalid option. LS must be TRUE or FALSE."
#else
#option USART_LS = false
#endif

Note that threads involving MrDEB can run a bit long, see:

Last edited:

Pommie

Well-Known Member
Note that threads involving MrDEB can run a bit long, see:
Stop it. That pain had diminished.

Mike.

Dan Soze

Member
Stop it. That pain had diminished.
hexreader should be forewarned wherein he treads.

Where is your compassion?

If we try maybe we can actually help MrDEB to a better place.

If we fail how about a thread that runs more than 400 posts?

Macbeth, Act 5, Scene5, Line 25.

be80be

Well-Known Member
What do you think happens here
Code:
While true
SetAllDigital
Cls
WriteAt(1,1,"Hello World")
Wend
your code just keeps clearing the screen as fast as it writes it.

Member
hexreader should be forewarned wherein he treads.
Many thanks - forewarned is fore-armed.
Much appreciated.

This thread motivated me to download Swordfish BASIC and the manual - now that I have tried it, I hate it - ROFL

be80be

Well-Known Member
Code:
delayms(1000)
like
Code:
SetAllDigital
While true
Cls
WriteAt(1,1,"Hello World")
delayms(1000)
Wend

MrDEB

Well-Known Member
will give it a go Be80using the example from the samples included w/ swordfish but will try the delay.
Jonsea suggested along time ago to include the use of a crystal. Waiting on parts I ordered from Sparkfun.
This thread will be historic as it won't go past 2 pages

Ian Rogers

User Extraordinaire
Forum Supporter
This thread will be historic as it won't go past 2 pages
So what if it does.... You take your time.... Members don't have to read it.... If you want to break a record, lets go for it!!

be80be

Well-Known Member
I just reposted what you posted MrDeb
The CLS clears the screen you wrapped it inside a loop while wend
So this is what happens the loop goes as fast as it can setting and clearing the screen faster then you can see it as a matter of
fact faster then it can more then likely write it.

Pommie

Well-Known Member
So what if it does.... You take your time.... Members don't have to read it.... If you want to break a record, lets go for it!!
I'm kinda looking forward to it in a nostalgic kinda way.

Mike.

be80be

Well-Known Member
Whats funny is ok 18f4520. cost 6 bucks MrBed you really need a newer basic that can use the newer 16fxxxx chip's

Pommie

Well-Known Member
Whats funny is ok 18f4520. cost 6 bucks MrBed you really need a newer basic that can use the newer 16fxxxx chip's
Or just learn C. Oh wait!

Mike.

MrDEB

Well-Known Member
been looking at C but at my age I feel it would be three steps backward.
have chips on order

Pommie

Well-Known Member
I'm 61 and C works for me.

Mike.

MrDEB

Well-Known Member
but to learn something new.
After a bypass surgery a year ago my short term memory is not real sharp.
for the small projects I am playing with Swordfish seems fine but maybe need to rethink what pic I am using.

MrDEB

Well-Known Member
I moved things around and still get only white squares.
checked and rechecked wiring with ohm meter etc.
thinking maybe because I have the Vcc and VSS daisy chaned on a perf board? could also be in need of a crystal but have operated with good results before.
going to rewire but that dosen't explain why SAME board worked before. BAD LCD? been trying using three different LCD modules.

MrDEB

Well-Known Member
Houston we have landed!!
used a different perf without daisy chaining the VCC or VSS and a different code (one I used for reading a keypad)
The LCD displays text (turns out one of the LCD modules was bad, circular filed it) now I can progress on this project.
Waiting for tactle switches w/LEDs