User manual

F1 LV Evaluation Platform User’s Guide
DS41614A-page 30 2011 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.
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 LV
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 PIC16LF1947 data sheet (DS41414).
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.
FIGURE 5-6:
Simply place the number you want displayed in each digit position and call
lcd_display_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;