View previous topic :: View next topic |
Author |
Message |
Markdem
Joined: 24 Jun 2005 Posts: 206
|
editing LCD.c driver |
Posted: Tue Aug 07, 2007 7:13 pm |
|
|
Hi All, I know that this could be done with the flex driver, but i would still like to know what the following two line mean in the ccs lcd.c driver
#byte lcd = 0xF81 (when using port b)
and
#byte lcd = 6 (when using port b)
I had a look in the datasheets, thinking it was a memory location, but the location on the datasheet for port b is 0xf85.
Could sombody please tell me what he two line do.
Thanks, Mark |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Wed Aug 08, 2007 8:29 am |
|
|
for lack of a better term, they "overlay" the variable created((lcd)) on top
of a memory location.
But these locations are special in that they are i/o ports.
The pins will still need the tris set properly,
but after that if you can say
lcd=0b01000100; //that is how the pin will be set.
and the same goes for reading.
int8 my_new_var;
my_new_var=lcd;//this reads the values on the pins.
ALSO keep in mind that different chips have the ports in different mem locations.
ie look at 18F452 spec page 47(45)
Last edited by treitmey on Wed Aug 08, 2007 9:01 am; edited 3 times in total |
|
|
Ttelmah Guest
|
|
Posted: Wed Aug 08, 2007 8:49 am |
|
|
Question. Which data sheet has portb, at F85?. It is F81, on all the '18' chips I have used. 0xF85, is normally portf....
Double check the sheet.
The '6' location, is for '16' chips which have the ports mapped at the bottom of memory, instead of the top.
Best Wishes |
|
|
Markdem
Joined: 24 Jun 2005 Posts: 206
|
|
Posted: Wed Aug 08, 2007 4:48 pm |
|
|
Thanks for that guys.
So my asamption was almost right. I did not see that the code is checking to see if I am using a 16F or 18F chip.
I should of said that ia am planing on using a 16F690, so i will need to use "#byte LCD = 7" if i want to use PORTC.
Ttelmah, you are right, 0xF85 is the TRISC location on the 16 chips, I just did not understand what the code was doing.
One more question, i checked that CCS help file, but still dont quite understand what #byte does. Is it just like declaring a veriable and then settting a vlaue for it?
Thanks, Mark |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Thu Aug 09, 2007 9:37 am |
|
|
Read my above reply.
What is read from the variable is the voltage level of the pins.
What is written to the variable is voltage set on pins.
that is 0 or 5V
but you need to set the tris |
|
|
|