Download CodeVisionAVR User Manual - La documentation de Thierry
Transcript
CodeVisionAVR
/* display the time and date continuously */
while (1)
{
/* read the time from the RTC */
rtc_get_time(&hour,&min,&sec);
/* read the date from the RTC */
rtc_get_date(&week_day,&day,&month,&year);
/* display the time on the LCD */
sprintf(display_buffer,"Time: %2d:%02d:%02d\n",hour,min,sec);
lcd_clear();
lcd_puts(display_buffer);
/* display the date on the LCD */
sprintf(display_buffer,"Date: %2d/%02d/%d",day,month,2000+year);
lcd_puts(display_buffer);
}
delay_ms(500); /* 0.5 second delay */
}
DS1307 example using the hardware TWI Functions for Master Mode Operation for XMEGA
Devices.
The chip is connected to the TWI of PORTD (TWID) of an ATxmega128A1.
/* include the DS1307 functions for TWI */
#include <ds1307_twi.h>
/* include the LCD Functions
The connections must be specified in the
Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu */
#include <alcd.h>
/* include the prototype for sprintf */
#include <stdio.h>
/* include the prototypes for the delay functions */
#include <delay.h>
char display_buffer[17]; /* LCD display buffer for 1 line */
/* structure that holds information used by the TWID master
for performing a TWI bus transaction */
TWI_MASTER_INFO_t twid_master;
/* interrupt service routine for TWID master */
interrupt [TWID_TWIM_vect] void twid_master_isr(void)
{
twi_master_int_handler(&twid_master);
}
/* TWI clock rate [Hz] */
#define TWI_CLK_RATE 100000
© 1998-2015 HP InfoTech S.R.L.
Page 522
Related documents
CodeVisionAVR User Manual
CodeVisionAVR User Manual
JARDUINO MANUAL DE USUARIO v1.2 beta
Xvhu#Pdqxdo# - book.isito.kg(0)
Full report - ECE - Cornell University
ThaiEasyElec - 2.8-inch TFT Touch Shield -EN
OLED Display User Manual ER-OLED032-1 Series
UG-5664ASYDF01 Evaluation Kit User Guide
SERVICE MANUAL MU-A18WV - MU-A24WV - MU-A30WV
"user manual"