How to move an LCD to a different port?

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
metric
Posts: 8
Joined: Sat Sep 27, 2008 7:16 pm

How to move an LCD to a different port?

Post by metric »

Hi Matrix team and all, first post here.

The LCD examples supplied with flowcode shows it connected to the port B. I want to use
this port rather as input port (because of its I/O's ability to generate interrupt on change),
and use port A for an LCD. I have push buttons block connected to the port B which
is configured as input now at the beginning of the flow.

What do I change in the flow to do this? I could not find any information about
port configuration in supplied example - it is hidden from the user.
for instance TUT_29.fcf which just prints "hello world".

The LCD is connected to the port B, and the program starts
with calling a macro sending the string to it. Nowhere in the
flow I can see port B even set to be an output. The only way I see for PIC
to know is because on LCD component, under "Component connection" you can
choose the port and this may get compiled as set the port up. If so,
I suppose I don't need now to explicitly initialize "Make port B an output",
but this is not immediately obvious. Also, nowhere in the flow
it says use one nibble of Port B only. (what if my end project will have 8 data
lines display, not 4 - where do I go to change to make it work?)
Is this in a macro? If so how can I see/modify such macro contents?

Well, for now the problem is if I make connection to the port A (and of course plug the
LCD block to the port A,) it doesn't work, I'm afraid not even get initialized.

Any advice what to look for in the flow while moving periphery between ports
will be appreciated.

My hardware (PIC config words) may not be set properly, any pointers how it is done
would be good. I'm trying 18PIC2321 and use HS in config word. Right now the words
are set like this:

Config 1L 0x00
Config 1H 0x02
Config 2L 0x18
Config 2H 0x1E
Config 3L 0x00
Config 3H 0x81
Config 4L 0xB1
Config 4H 0x00
Config 5L 0x03
Config 5H 0xC0

Actually, any working example (fcf file) of LCD usage with 18F2xxx PICs I can look at would be
helpful. I suspect my project is not starting, so the proper PIC configuration settings (for F2321
or such) are the most needed information.

Thank you all,

Victor

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: How to move an LCD to a different port?

Post by Steve »

The LCD component currently only works in 4-bit "nibble" mode (you'll need to wait for v4 for 8-bit mode).

Changing the LCD port should be as simple as changing the component connections. But there are a few other things you need to be careful of - for example, make sure the clock speed within Flowcode is the same as your actual hardware.

The best thing to do is to start with a basic led flasher program (or similar) and make sure the program works and the timing seems ok. Once you have done this, create a very simple LCD program (remember to call the "start" macro first) and get this working.

I hope this helps. If you have a problem with either of these wimple steps, please upload your program and we'll have a look to see what's wrong.

metric
Posts: 8
Joined: Sat Sep 27, 2008 7:16 pm

Re: How to move an LCD to a different port?

Post by metric »

Steve, this is generous offer (to upload my program for inspection) and next time I'll do that. For now I could not get
an LCD running so unfortunately had to drop this idea and use LEDs to display status. Perhaps timing
indeed was wrong but how exactly to check it if the LCD is not displaying? Physically use a scope to inspect
clock-in line to the LCD in provided working examples and tweak delays in my flow to match?

BTW, I believe there is a bug in "Chip->Clock Speed..." menu: the lower the number you type
in Clock Speed (Hz) field (assuming internal oscillator choice is used) - the faster actual hardware runs.
So it seems there is inverse relation as if you really type clock period, not the frequency.
If you'd type frequency [of PIC's internal clock, right?], the larger number - the faster hardware
would run. Well it is opposite.

For refrence = for PIC18F88, if I use 1 second delay in a flow chart, actual delay on the hardware
is about 1 sec if this "frequency" number is 30000. Don't know what exactly this number represents.

Thank you in advance for comment on this.

Victor

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: How to move an LCD to a different port?

Post by Steve »

This "bug" is a misconception that is common for new users. The "clock speed" setting, does NOT set the actual clock speed of the device. The actual clock speed of the device is determined by the hardware (e.g. the actual clock crystal value or RC combination) and the configuration bits.

You must set the "clock speed" setting within Flowcode to this actual clock speed value for your program to behave correctly - especially when you are doing any communications with ther chips (including an LCD).

If you are using the internal oscillator, I think this defaults to 4MHz, so this is the value you will need to set in the "clock speed" dialog.

metric
Posts: 8
Joined: Sat Sep 27, 2008 7:16 pm

Re: How to move an LCD to a different port?

Post by metric »

Steve, please elaborate - what exactly this number affects?

I can set the number to whatever you say is required.
Is it being downloaded to actual hardware?

So, let me understand: say, 4MHz crystal is fitted on the multiprogrammer board.
Are you saying, not only configuration bits have to be set to "HS", but also
speed has to be set to 4000000 for the program to run on the hardware
as expected? I know "HS" setting is downloaded into the pic in configuration
bits. Where in the PIC exactly a 4000000 number is downloaded and resign then?

Or it only affects actual code (like delays) making amount of ms or seconds match
expected? So providing frequency number of MHz is a way to tell flowcode how many
cycles of clocks to use in delays and such subroutines to make timing what I expect
it should be when "delay" icons are used?

Victor

Victor

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: How to move an LCD to a different port?

Post by Steve »

metric wrote:Or it only affects actual code (like delays) making amount of ms or seconds match
expected? So providing frequency number of MHz is a way to tell flowcode how many
cycles of clocks to use in delays and such subroutines to make timing what I expect
it should be when "delay" icons are used?
That's the reason. Flowcode has no way of "knowing" what crystal value (etc) is actually attached to the microcontroller.

metric
Posts: 8
Joined: Sat Sep 27, 2008 7:16 pm

Re: How to move an LCD to a different port?

Post by metric »

Got it, thank you. The issue then is how do I set internal oscillator frequency then
before I let flowcode know what it is? I needed all pins as I/Os so I use
internal oscillator and in case of 16F88 there are several choices of user selectable
frequencies (per data sheet: 31, 125, 250, 500 kHz, 1,2, 4 and 8 MHz).

So is there a way to select the frequency I want other than by typing HEX numbers
directly in Config1 and Config2 configuration words in expert configuration dialog window?
These numbers affect many more important settings than just frequency and I'd rather
use dedicated means of the flowcode (if any exist) to choose the frequency,
leaving everything else alone.

Any suggestions?

Thank you.

Victor

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: How to move an LCD to a different port?

Post by Steve »

Typing the HEX numbers in directly is the only way for now, unless you are using our own programming software ("PPPv3"). You could run the PPPv3 utility separately and get the appropriate configuration data (remember to use the "expert" configuration screen). See the picture below.

When using the internal oscillator, you may also want to set the clock speed to something other than the default 4MHz. To do this, search this forum for the word "osccon".
Attachments
PPP_88_config.JPG
PPP_88_config.JPG (68.77 KiB) Viewed 5804 times

Post Reply