Microchip Technology DM164130-2 User Manual
F1 Evaluation Platform User’s Guide
DS41401B-page 24
2010 Microchip Technology Inc.
FIGURE 5-4:
5.6.2.5
i2c_handler
The i2c_handler function must be called for each I
2
C state to be handled. This
function can be placed into the Interrupt Service Routine for your application or, you
can simply poll it often. If the i2c_write_block or i2c_read_block functions are
used when the driver is configured for polling, then this function will repeatedly be
called until the transaction completes.
can simply poll it often. If the i2c_write_block or i2c_read_block functions are
used when the driver is configured for polling, then this function will repeatedly be
called until the transaction completes.
FIGURE 5-5:
5.7
USING THE LCD DRIVER
The supplied LCD driver configures the LCD module for the I/O pins used by the F1
Evaluation Platform. Icon definitions are provided to simplify the software. A BCD to
7-segment display mapping function is also provided to further simplify control of the
LCD glass. For more information concerning the LCD peripheral, please consult the
LCD chapter in the PIC16LF1937 data sheet (DS41364).
Evaluation Platform. Icon definitions are provided to simplify the software. A BCD to
7-segment display mapping function is also provided to further simplify control of the
LCD glass. For more information concerning the LCD peripheral, please consult the
LCD chapter in the PIC16LF1937 data sheet (DS41364).
5.7.1
LCD Data Structures
5.7.1.1
BCD_TYPE
To simplify BCD to the 7-segment display mapping, a BCD segment data type has been
provided. This data type is simply four 4-bit fields representing digits 0, 1, 2 and 3.
provided. This data type is simply four 4-bit fields representing digits 0, 1, 2 and 3.
FIGURE 5-6:
Simply place the number you want displayed in each digit position and call
lcd_display_digits
lcd_display_digits
. Digit 3 is the Most Significant ½ digit of the 3.5-digit LCD
glass. Therefore, the largest value displayable is 1FFF assuming hexidecimal digits or
1999
1999
for decimal digits.
Send_one_byte()
{
unsigned char data;
i2c_write_block(ADDRESS, 1, &data, i2c_200K);
}
Interrupt_service_routine()
{
i2c_handler();
}
typedef union
{
UINT16 val;
struct
{
unsigned digit0 : 4;
unsigned digit1 : 4;
unsigned digit2 : 4;
unsigned digit3 : 4;
};
} BCD_TYPE;