View previous topic :: View next topic |
Author |
Message |
pilar
Joined: 30 Jan 2008 Posts: 197
|
How to show a int16 in four 7segment display |
Posted: Thu Feb 04, 2010 9:52 am |
|
|
Hi, I am use a pic18f452 and need to show a variable int16 in four 7segment display, I developed the routine to multiplex the digits, but I do not understandhow transfer the value of variable int16 to 7-segment format, someone can tell me how to do it? |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Feb 04, 2010 10:45 am |
|
|
Do you want to display the full int16 range in hexadecimal or 0 .. 9999 in decimal format? |
|
|
icesynth
Joined: 03 Sep 2007 Posts: 32 Location: Edmonton, Alberta
|
|
Posted: Thu Feb 04, 2010 11:29 am |
|
|
Code: |
int8 i8_digit1, i8_digit2, i8_digit3, i8_digit4;
int16 i16_sourcenumber = 0xABCD;
i8_digit1 = (int8)( i16_sourcenumber & 0x000F );
i8_digit2 = (int8)(( i16_sourcenumber >> 4 ) & 0x000F );
i8_digit3 = (int8)(( i16_sourcenumber >> 8 ) & 0x000F );
i8_digit4 = (int8)( i16_sourcenumber >> 12 );
f_setsegmentvalue( SEGMENT1, i8_digit1 );
f_setsegmentvalue( SEGMENT2, i8_digit2 );
f_setsegmentvalue( SEGMENT3, i8_digit3 );
f_setsegmentvalue( SEGMENT4, i8_digit4 );
|
and just have f_setsegmentvalue translate to the display pattern, usually done by a lookup table. _________________ Programming for the the real world.
--Chris Burchett
Sylver Technologies Inc. |
|
|
|