|
|
View previous topic :: View next topic |
Author |
Message |
logical
Joined: 21 Dec 2009 Posts: 57 Location: SouthPort, UK
|
Bytes and Nibbles |
Posted: Sun Jan 03, 2010 8:13 pm |
|
|
Hi,
Am trying to find a faster solution than manually breaking a byte in to 2 separate nibbles, sure it works that way but I seem to recall PICC having a simple feature included to do this specifically.
The LCD Screen I use has to have 2 separate bytes sent to it for the column address (an upper and lower) Screen Controller is the "SH1101A"
What I am wanting to say split lcd_column into:
lcd_colhigh //higher nibble
lcd_collow //lower nibble
i.e:
Code: | write_c(0x00+col_lowbit); //column low bits
write_c(0x10+col_highbit); //column high bits
|
The only thing I could find as reference was #id in the CCS Help file, needless to say, I can't get my head round that one.
As per usual, thanks in advance for any help.
Chris |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jan 03, 2010 9:00 pm |
|
|
Look at this routine,
Code: | void lcd_send_byte(BYTE address, BYTE n) |
in this file:
Quote: | c:\program files\picc\drivers\lcd.c
|
I found this example by running a text search engine on the CCS
directories, with .c as the filespec, and searching for nibble.
You can do this by going to the c:\program files\PICC directory
in Windows Explorer and press the F3 key. |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Mon Jan 04, 2010 1:20 am |
|
|
PIC processors have a SWAPF instruction, that's used by CCS C for int8 shift operations, where suitable. |
|
|
logical
Joined: 21 Dec 2009 Posts: 57 Location: SouthPort, UK
|
|
Posted: Mon Jan 04, 2010 5:24 am |
|
|
Hi Guys,
Thanks for both replies, not a problem on either of those provided, ideally the solution I was trying to use (expected it to be the quickest) was the #ID as defined in the help manual, sadly I could not find out much info about it but if I can't then that is fine:
Quote: |
Syntax:
#ID number 16
#ID number, number, number, number
#ID "filename"
#ID CHECKSUM
Elements:
Number162 is a 16 bit number, number is a 4 bit number, filename is any valid PC filename and checksum is a keyword.
Purpose:
This directive defines the ID word to be programmed into the part. This directive does not affect the compilation but the information is put in the output file.
The first syntax will take a 16-bit number and put one nibble in each of the four ID words in the traditional manner. The second syntax specifies the exact value to be used in each of the four ID words.
When a filename is specified the ID is read from the file. The format must be simple text with a CR/LF at the end. The keyword CHECKSUM indicates the device checksum should be saved as the ID.
Examples:
#id 0x1234
#id "serial.num"
#id CHECKSUM
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jan 04, 2010 1:29 pm |
|
|
#ID is pre-processor command which is used to put data into a special
area of the PIC called the "Configuration Memory". The PIC data sheet
describes the "ID Locations" area.
Quote: |
12.16 ID Locations
Four memory locations (2000h - 2003h) are designated
as ID locations, where the user can store checksum or
other code identification numbers. These locations are
not accessible during normal execution, but are readable
and writable during program/verify. It is recommended
that only the 4 Least Significant bits of the ID location are used.
|
The purpose of the ID locations is so that the user (a company)
can put some identifying number in that location, such as a product
code or revision number.
The #ID directive can never be used for low-level coding purposes,
such as you require.
What you actually want is a set of functions or a macros, similar to
make8, make16, and make32, except that they work with nibbles
instead of bytes. |
|
|
logical
Joined: 21 Dec 2009 Posts: 57 Location: SouthPort, UK
|
|
Posted: Mon Jan 04, 2010 1:56 pm |
|
|
Thanks PCM, have clarified that very well, appreciated as usual :o) |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|