XC8 #2 TIMER1 INTERRUPT OVERFLOW VOLT AMP WAVE IN PROTEUS วัดโวลท์กระแสสัญญาณ
13/6/2562 SONGCHAI PRAPATRUNGSEE
XC8 #2 TIMER1 INTERRUPT OVERFLOW VOLT AMP WAVE IN PROTEUS วัดโวลท์กระแสสัญญาณ
ซื้อสินค้าราคาถูก https://c.lazada.co.th
ซื้อสินค้าราคาถูก https://c.lazada.co.th
/*
* File: XC8 TIMER1.c
* Author: sc
*
* Created on 10/6/2562, 17:02
*/
//INTERRUPT 5ms=200HZ, USE CRYSTAL4MHZ HS
#include <xc.h> //PIC16F877A
//#pragma config FOSC = HS //HS=CRYSTAL 4MHZ UP
#define YELLOW RB7
char i;
void __interrupt(high_priority) T1(void)//@4=VECTOR4
{
TMR1IF=0;//FLAG
TMR1H=0XEC;//8BIT HIGH
TMR1L=0X78;//8BIT LOW
i++;
if(i>=100)//5mS x 100=500mS
{
i=0;
YELLOW=~YELLOW;//! ~ USE SAME
}
}
void main()
{
TRISB7=0;
GIE=1;//GLOBAL INTERRUPT ENABLE BIT
PEIE=1;//PERIPHIRAL INTERRUPT ENABLE BIT
TMR1IE=1;//TIMER1 INTERRUPT ENABLE BIT
TMR1IF=0;//TIMER1 OVERFLOW INTERRUPT FLAG BIT
TMR1CS=0;//TIMER1 CLOCK SOURCE SELECT BIT
//T1CKPS1:T1CKPS0 =00=1:1....11=1:8 PRESCALE VALUE
T1CKPS1=0;//TIMER1 INPUT CLOCK PRESCALE SELECT BITS
T1CKPS0=0;//TIMER1 INPUT CLOCK PRESCALE SELECT BITS
T1SYNC=1;//TIMER1 EXTERNAL CLOCK INPUT SYNCHRONIZATION CONTROL BIT
TMR1H=0XB1;//TIMER1 HI BYTE
TMR1L=0XDF;//TIMER1 LOW BYTE
TMR1ON=1;//TIMER1 ON BIT
while(1);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น