CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Bytes and Nibbles

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
logical



Joined: 21 Dec 2009
Posts: 57
Location: SouthPort, UK

View user's profile Send private message Visit poster's website

Bytes and Nibbles
PostPosted: Sun Jan 03, 2010 8:13 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Jan 03, 2010 9:00 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jan 04, 2010 1:20 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Mon Jan 04, 2010 5:24 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jan 04, 2010 1:29 pm     Reply with quote

#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

View user's profile Send private message Visit poster's website

PostPosted: Mon Jan 04, 2010 1:56 pm     Reply with quote

Thanks PCM, have clarified that very well, appreciated as usual :o)
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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