?? runtime.c
字號:
/* ATmega103 runtime.c file
Author : Robert Stuart
Company : PDL Industries Ltd
Date of Creation : 21 July 1999
Tested : not yet
Function :
*/
/* include */
#include "runtime.h"
void RuntimeInitialise( void )
{
TCCR1B = 0; /* Stop T1 */
TCNT1 = 0; /* Clear T1 */
OCR1A = _1MS_INTERRUPT; /* Set Compare A - 1ms */
TIMSK = BIT(OCIE1A); /* Compare A interrupt enabled */
TCCR1B = BIT(CS10) | BIT(CTC1);
}
void RuntimeInterrupt( void )
{
ReadButtons();
RefreshImportantRegisters();
DelayLCDStartup();
CheckPower();
WriteLCDMessage();
SampleADC();
WDR;
}
void SampleADC( void )
{
unsigned int ADCValue[8];
unsigned char Channel;
for ( Channel=0; Channel<8; Channel++ )
{
ADMUX = Channel; /* select channel */
ADCSR |= BIT(ADSC);
while ( ADCSR & BIT(ADSC) ); /* wait until conversion is finished */
ADCValue[Channel] = ADCL; /* read lower bytes first */
ADCValue[Channel] += ADCH << 8; /* sample at 10-bit resolution */
}
}
void WriteLCDMessage( void )
{
static unsigned int Counter;
char str1[17], str2[17];
if ( Counter++ > _500MS )
{
Counter = 0;
sprintf( str1, "Time %02d:%02d:%02d", Time.Hour, Time.Minute, Time.Second );
sprintf( str2, "Date %02d-%s-%04d", Time.Day, Calender[Time.Month], Time.Year );
LCDPrintf( str1, str2 );
}
}
void RefreshImportantRegisters( void )
{
DDRD = CONFIGURE_PORTD;
DDRE = CONFIGURE_PORTE;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -