Yes it was packed 16bits. And 3 days ago I was almost there but did it the otherway round i.e. AND 0xf000, 0x0f00 etc followed by the shift. My error was && instead of & (Double Doh!!). It works perfectly now thanks. Ian ------------------------------------------------------ http://mdm1.bravepages.com Technical support for the Multifunction Display Module ------------------------------------------------------ > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Brent Brown > Sent: 03 August 2002 23:26 > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [PIC]: Serial Output with Hi Tec C > > > Doh! It just occurred to me that your 4 digit BCD number is probably > "packed" into 16 bits (4 x 4 bit digits). > > In that case this should work: > > SendByte(((number >> 0) & 0x000f) + '0'); > SendByte('0'); > SendByte(((number >> 4) & 0x000f) + '0'); > SendByte(((number >> 8) & 0x000f) + '0'); > SendByte(((number >> 12) & 0x000f) + '0'); > > The shift right by 0 places for the first digit is obviously > redundant, as is the AND by 0x000f for the 4th digit, but I like to > keep things looking consistent so it's easier to see what it is > intended. > > This should optimise quite nicely in Hi-Tech C, perhaps you can get > away without some of the extra brackets too. > > -- > Brent Brown, Electronic Design Solutions > 16 English Street, Hamilton, New Zealand > Ph/fax: +64 7 849 0069 > Mobile/txt: 025 334 069 > eMail: brent.brown@clear.net.nz > > -- > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > > > --- > Incoming mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.380 / Virus Database: 213 - Release Date: 24/07/02 > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.380 / Virus Database: 213 - Release Date: 24/07/02 -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu