Kesme alt programını çalıştıramıyorum bu işten anlayan var mı?
(https://i.ibb.co/WPnpB8v/Ekran-Al-nt-s.png) (https://ibb.co/WPnpB8v)
Timer'ı başlatan, frekansını ayarlayan, interrupt izni veren kod gerekir. Bu işler yapılmadan interrupt kendiliğinden çalışmaz
Şuna benzer bir kod gerekir
/*
* 8051_Timer_Interrupt
* http://www.electronicwings.com
*/
#include...
void Timer_init()
{
TMOD = 0x01; /* Timer0 mode1 */
TH0 = 0x4C; /* 50ms timer value */
TL0 = 0x00;
TR0 = 1; /* Start timer0 */
}
void Timer0_ISR() interrupt 1 /* Timer0 interrupt service routine (ISR) */
{
test = ~test; /* Toggle port pin */
TH0 = 0x4C; /* 50ms timer value */
TL0 = 0x00;
}
int main(void)
{
EA = 1; /* Enable global interrupt */
ET0 = 1; /* Enable timer0 interrupt */
Timer_init();
while(1);
}
Tabi buyrun
(https://i.ibb.co/pjfjsf8/dscv.png) (https://ibb.co/pjfjsf8)
#include "reg24le1.h" // I/O header file for NRF24LE1
#include <stdlib.h> // standard library
#include <stdio.h> // standard I/O library
int counter;
int counter2;
void ISR_Timer0(void) interrupt 1
{
if(TF1==1){
counter++;
if(counter>=20){
P03=~P03;
counter=0;
}
TF1=0;
TH1=0X4B;
TL1=0XFE;
}
}
void main()
{
P0DIR = 0; // Port1 as output
P03 = 0; // Pin 0 of Port 1 low
EA = 1; // Enable global interrupt
TMOD = 17 ; // timer0 in 16bit mode1
TR1=1;
// infinite loop
while(1);
}
Alıntı yapılan: a.serhatboz - 23 Kasım 2022, 13:11:13#include "reg24le1.h" // I/O header file for NRF24LE1
#include <stdlib.h> // standard library
#include <stdio.h> // standard I/O library
int counter;
int counter2;
void ISR_Timer0(void) interrupt 1
{
if(TF1==1){
counter++;
if(counter>=20){
P03=~P03;
counter=0;
}
TF1=0;
TH1=0X4B;
TL1=0XFE;
}
}
void main()
{
P0DIR = 0; // Port1 as output
P03 = 0; // Pin 0 of Port 1 low
EA = 1; // Enable global interrupt
TMOD = 17 ; // timer0 in 16bit mode1
TR1=1;
// infinite loop
while(1);
}
Hocam bu programda while(1)in içinde program koşturabilir miyiz
Sorunu çözdüm herkese teşekkür ederim (Timer kesmesi aktif etme bitini 1 yapmamışım)
Tabi ki neden koşturamayasınız