Exemplo n.º 1
0
int main()
{    
    uint8 ch;           /* Data sent on the serial port */
    uint8 count = 0u;    /* Initializing the count value */
    uint8 pos = 0u;

    CyGlobalIntEnable; 

    isr_1_Start();      /* Initializing the ISR */
    UART_1_Start();     /* Enabling the UART */
    LCD_Char_1_Start(); /* Enabling the LCD */

        
    for(ch = START_CHAR_VALUE; ch <= END_CHAR_VALUE; ch++)
    {
        UART_1_WriteTxData(ch); /* Sending the data */

        count++;        
        if(count % LCD_NUM_COLUMNS == 0u) /* If the count value reaches the count 16 start from first location */
        {
            pos = 0u;  /* resets the count value */
            LCD_Char_1_WriteControl(LCD_Char_1_CLEAR_DISPLAY); /* Display will be cleared when reached count value 16 */
        }    

        LCD_Char_1_Position(0u, pos++);   /* LCD position to the count++ */
        LCD_Char_1_PutChar(ch);         /* print the value in the LCD */
                
        LCD_Char_1_Position(1u, 0u);
        LCD_Char_1_PrintInt8(count);    /* prints the count in the LCD */
        CyDelay(200u);
    }

    for(;;) {}
}
Exemplo n.º 2
0
/*******************************************************************************
* Function Name: LCD_Char_1_Init
********************************************************************************
*
* Summary:
*  Perform initialization required for the components normal work.
*  This function initializes the LCD hardware module as follows:
*        Enables a 4-bit interface
*        Clears the display
*        Enables the auto cursor increment
*        Resets the cursor to start position
*  Also, it loads a custom character set to the LCD if it was defined in the customizer.
*
* Parameters:
*  None.
*
* Return:
*  None.
*
* Reentrant:
*  No.
*
*******************************************************************************/
void LCD_Char_1_Init(void) 
{
    /* INIT CODE */
    CyDelay(40u);                                                        /* Delay 40 ms */
    LCD_Char_1_WrCntrlNib(LCD_Char_1_DISPLAY_8_BIT_INIT);    /* Selects 8-bit mode */
    CyDelay(5u);                                                         /* Delay 5 ms */
    LCD_Char_1_WrCntrlNib(LCD_Char_1_DISPLAY_8_BIT_INIT);    /* Selects 8-bit mode */
    CyDelay(15u);                                                        /* Delay 15 ms */
    LCD_Char_1_WrCntrlNib(LCD_Char_1_DISPLAY_8_BIT_INIT);    /* Selects 8-bit mode */
    CyDelay(1u);                                                         /* Delay 1 ms */
    LCD_Char_1_WrCntrlNib(LCD_Char_1_DISPLAY_4_BIT_INIT);    /* Selects 4-bit mode */
    CyDelay(5u);                                                         /* Delay 5 ms */

    LCD_Char_1_WriteControl(LCD_Char_1_CURSOR_AUTO_INCR_ON);    /* Incr Cursor After Writes */
    LCD_Char_1_WriteControl(LCD_Char_1_DISPLAY_CURSOR_ON);      /* Turn Display, Cursor ON */
    LCD_Char_1_WriteControl(LCD_Char_1_DISPLAY_2_LINES_5x10);   /* 2 Lines by 5x10 Characters */
    LCD_Char_1_WriteControl(LCD_Char_1_DISPLAY_CURSOR_OFF);     /* Turn Display, Cursor OFF */
    LCD_Char_1_WriteControl(LCD_Char_1_CLEAR_DISPLAY);          /* Clear LCD Screen */
    LCD_Char_1_WriteControl(LCD_Char_1_DISPLAY_ON_CURSOR_OFF);  /* Turn Display ON, Cursor OFF */
    LCD_Char_1_WriteControl(LCD_Char_1_RESET_CURSOR_POSITION);  /* Set Cursor to 0,0 */
    CyDelay(5u);

    #if(LCD_Char_1_CUSTOM_CHAR_SET != LCD_Char_1_NONE)
        LCD_Char_1_LoadCustomFonts(LCD_Char_1_customFonts);
    #endif /* LCD_Char_1_CUSTOM_CHAR_SET != LCD_Char_1_NONE */
}
Exemplo n.º 3
0
/*******************************************************************************
* Function Name: LCD_Char_1_LoadCustomFonts
********************************************************************************
*
* Summary:
*  Loads 8 custom font characters into the LCD Module for use.  Cannot use
*  characters from two different font sets at once, but font sets can be
*  switched out during runtime.
*
* Parameters:
*  customData:  pointer to a constant array of 64 bytes representing 8 custom
*               font characters.
* Return:
*  None.
*
* Theory:
*  Prior to using this function user need to import the pointer to custom
*  font array to your project by writting the following in the source code file 
*  where custom font will be used: 
*       extern uint8 const CYCODE LCD_Char_customFonts[];
*  This function is not automatically called by the Start() routine and must be
*  called manually by the user. 
*******************************************************************************/
void LCD_Char_1_LoadCustomFonts(const uint8* customData) 
{
    uint8 indexU8;

    LCD_Char_1_IsReady();
    /* Set starting address in the LCD Module */
    /* Optionally: Read the current address to restore at a later time */
    LCD_Char_1_WriteControl(LCD_Char_1_CGRAM_0);

    /* Load in the 64 bytes of CustomChar Data */
    for(indexU8 = 0u; indexU8 < LCD_Char_1_CUSTOM_CHAR_SET_LEN; indexU8++)
    {
        /* Delay between each write */
        LCD_Char_1_WriteData(customData[indexU8]);
    }

    LCD_Char_1_IsReady();
    LCD_Char_1_WriteControl(LCD_Char_1_DDRAM_0);
}
Exemplo n.º 4
0
/*******************************************************************************
*  Function Name: LCD_Char_1_Position
********************************************************************************
*
* Summary:
*  Moves the active cursor location to a point specified by the input arguments
*
* Parameters:
*  row:    Specific row of LCD module to be written
*  column: Column of LCD module to be written
*
* Return:
*  None.
*
* Note:
*  This only applies for LCD displays that use the 2X40 address mode.
*  In this case Row 2 starts with 0x28 offset from Row 1.
*  When there are more than 2 rows, each row must be fewer than 20 characters.
*
*******************************************************************************/
void LCD_Char_1_Position(uint8 row, uint8 column) 
{
    switch (row)
    {
        case (uint8)0:
            LCD_Char_1_WriteControl(LCD_Char_1_ROW_0_START + column);
            break;
        case (uint8) 1:
            LCD_Char_1_WriteControl(LCD_Char_1_ROW_1_START + column);
            break;
        case (uint8) 2:
            LCD_Char_1_WriteControl(LCD_Char_1_ROW_2_START + column);
            break;
        case (uint8) 3:
            LCD_Char_1_WriteControl(LCD_Char_1_ROW_3_START + column);
            break;
        default:
            /* if default case is hit, invalid row argument was passed.*/
            break;
    }
}