main.c File Reference


Detailed Description

Demonstration application. Prints STK502 on LCD.

Application note:
AVR065: LCD Driver for the STK502
Documentation:
For comprehensive code documentation, supported compilers, compiler settings and supported devices see readme.html
Author:
Atmel Corporation: http://www.atmel.com
Support email: avr@atmel.com
Name
RELEASE_1_1
Revision
1.3
RCSfile
main.c,v
Date
2006/02/16 18:14:01

Definition in file main.c.

#include "defines.h"
#include "LCD_driver.h"
#include <inavr.h>

Include dependency graph for main.c:

Go to the source code of this file.

Defines

#define DELAY1   64
 Main function which contains the endless main loop.
#define DELAY2   5

Functions

void LCD_timerDelay (unsigned char delay)
 Generate a delay that depends on the LCD clock rather than the system clock.
void main (void)


Define Documentation

#define DELAY1   64
 

Main function which contains the endless main loop.

Definition at line 47 of file main.c.

Referenced by main().

#define DELAY2   5
 

Definition at line 48 of file main.c.

Referenced by main().


Function Documentation

void LCD_timerDelay unsigned char  delay  ) 
 

Generate a delay that depends on the LCD clock rather than the system clock.

Parameters:
delay - number of LCD frames to delay the subsequent code execution.

Definition at line 34 of file main.c.

References FALSE, LCD_status, LCD_timer, TRUE, _LCD_status::updateComplete, and _LCD_status::updateRequired.

Referenced by main().

00035 {
00036   __disable_interrupt();
00037   LCD_timer = delay;                          //Plant LCD_timer seed to generate delay - delay*(1/[LCD frame rate])
00038   LCD_status.updateComplete = FALSE;          //Clear updateComplete to be able to test if LCD interrupt has been served
00039   LCD_status.updateRequired = TRUE;           //Request update of the LCD to let the LCD ISR clear set updateComplete
00040   __enable_interrupt();
00041   while( !LCD_status.updateComplete );        //Don't update the LCD_displayData into LCD has been updated
00042 }

void main void   ) 
 

Definition at line 50 of file main.c.

References DELAY1, DELAY2, FALSE, LCD_CONTRAST_LEVEL, LCD_Init(), LCD_SET_COLON, LCD_status, LCD_timerDelay(), LCD_WriteDigit(), TRUE, _LCD_status::updateComplete, and _LCD_status::updateRequired.

00051 {
00052     unsigned char counter;
00053     unsigned char testString[] = "STK502";
00054     LCD_Init();                 // initialize the LCD
00055 
00056     __enable_interrupt();
00057 
00058     for(;;)                    //endless main loop
00059     {
00060 //----------------------------------------------------------
00061 // Display a single character from the testString at a time
00062 //----------------------------------------------------------
00063       for (counter = 0; counter < 6; counter++ )
00064       {
00065         while( !LCD_status.updateComplete );        //Don't update the LCD_displayData into LCD has been updated
00066         LCD_status.updateRequired = FALSE;          //Block the updating of the LCD while accessing LCD_displayData
00067 
00068         LCD_WriteDigit( *(testString + counter), counter+2 ); //Write new data to LCD_displayData
00069 
00070         LCD_status.updateComplete = FALSE;          //Clear LCD_updateComplete flag to indicate that LCDdisplayData
00071                                                     // has been updated, but LCD has not been updated yet.
00072         LCD_status.updateRequired = TRUE;           //Request update of the LCD (release LCD update blocking).
00073       }
00074        while( !LCD_status.updateComplete );         //Make sure that the LCD_displayData has been latched
00075 
00076 //----------------------------------------------------------
00077 // Flash the two Colons on the LCD
00078 //----------------------------------------------------------
00079       LCD_status.updateRequired = FALSE;          //Block the updating of the LCD while accessing LCD_displayData
00080       LCD_SET_COLON(TRUE);                        //Display the colons in the LCD
00081       LCD_timerDelay( DELAY1 );                   //Call LCD interrupt controlled delay
00082 
00083       LCD_status.updateRequired = FALSE;          //Block the updating of the LCD while accessing LCD_displayData
00084       LCD_SET_COLON(FALSE);                       //Hide the colons in the LCD
00085       LCD_timerDelay( DELAY1 );                   //Call LCD interrupt controlled delay
00086 
00087 //----------------------------------------------------------
00088 // Vary the contrast level between min and max and min, and back to norm
00089 //----------------------------------------------------------
00090       for(counter = 0x00; counter < 0x0F; counter++)  //Increase LCD contrast to max, in smallest steps
00091       {
00092         LCD_CONTRAST_LEVEL(counter);
00093         LCD_timerDelay( DELAY2 );                   //Call LCD interrupt controlled delay
00094       }
00095       for(counter = 0x0F; counter != 0x00; counter--)  //Decrease LCD contrast to min, in smallest steps
00096       {
00097         LCD_CONTRAST_LEVEL(counter);
00098         LCD_timerDelay( DELAY2 );                   //Call LCD interrupt controlled delay
00099       }
00100       LCD_CONTRAST_LEVEL( LCD_INITIAL_CONTRAST );   //Contrast level back to initial level
00101 
00102 //----------------------------------------------------------
00103 // Clear all LCD digits in within one LCD opdate
00104 //----------------------------------------------------------
00105       while( !LCD_status.updateComplete );          //Wait for last LCD update to complete
00106       LCD_status.updateRequired = FALSE;            //Disable further LCD updating
00107       for (counter = 2; counter < 8; counter++ )
00108       {
00109             LCD_WriteDigit( '-', counter );         //Update LCD_displayData buffer
00110       }
00111       LCD_status.updateRequired = TRUE;             //Enable LCD opdating
00112       while( !LCD_status.updateComplete );          //Make sure that the LCD_displayData has been latched...
00113      }
00114 }

Here is the call graph for this function:


Generated on Fri Feb 17 12:31:58 2006 for AVR065: LCD Driver for the STK502 by  doxygen 1.4.5