📄 main.c.bak
字号:
//==============================================================================
// DEVICE = PICC-18
// VERSION = 1.0
// DATE = 11.08.2007
// LAST CHANGE = -
// Developer = Keith Yuen
// =============================================================================
// Description: ADC Driver demo for PIC18F4455
// =============================================================================
#include <pic18.h>
#include "delay.h"
#include "adc.h"
#include "glcd.h"
void PortInit(void)
{
TRISD = 0b00000000;
TRISC = 0b00000000;
TRISB = 0b00000000;
TRISA = 0b11111111;
}
void TimerInit(void)
{
//TIMER
TMR0IE = 1;
TMR0H = 0xD1; //1ms
TMR0L = 0xDF;
T0CON = 0x08; //
TMR0ON = 1; //ON TIMER
}
void main()
{
unsigned char value;
//OFF WatchDog
SWDTEN = 0;
//INTERRUPT
INTCON = 0; // reset all the flag bits for all the interrupts
GIE = 1; // global interrupt enable bit (1: enable all)
PortInit();
TimerInit();
ADC_Init();
DelayMs(50);
GLCD_Init();
GLCD_WriteAlignString("ADC DEMO", 0, GLCD_ALIGN_CENTER);
GLCD_WriteAlignString("ADC : ", 2, GLCD_ALIGN_LEFT);
while(1)
{
ADC_Convert();
GLCD_SetPos(2, GLCD_charPos[6]);
ADC_Wait();
value = ADC_GetByte();
GLCD_WriteDec(value);
DelayMs(250);
}
}
//1ms interrupt
void interrupt prv_int(void)
{
static unsigned char tick10ms = 0;
static unsigned char tick1ms = 0;
if (!TMR0IF)
return;
TMR0IF = 0;
TMR0H = 0xD1; //1ms
TMR0L = 0xDF;
tick1ms++;
if (tick1ms == 10)
{
tick1ms = 0;
////////////////////////
//10ms ACTION HERE:
tick10ms++;
if (tick10ms == 100)
{
tick10ms = 0;
////////////////////////
//1s ACTION HERE:
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -