9463 views|21 replies

11

Posts

0

Resources
The OP
 

I have been away from microcontrollers for more than 8 years. Now I am back to microcontrollers, but I still don’t understand timing interrupts. Please help me!!! [Copy link]

 
Please help me, it needs to be solved urgently before the New Year; thank you all
This post is from MCU

Latest reply

It is not advisable to set the timer in the while loop of the main function, otherwise it will affect the timing accuracy. .  Details Published on 2019-2-3 17:24
 

1w

Posts

204

Resources
2
 
What is the specific problem? What is the question about?
This post is from MCU
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
 
 

6366

Posts

4936

Resources
3
 
Everyone is willing to help you, but they don't know what you want to do.
This post is from MCU
 
 
 

6366

Posts

4936

Resources
4
 
First, tell me what kind of microcontroller you use, then why you want to use the timer interrupt, what function to achieve, and where is it stuck at the moment? Is the interrupt service program incorrect? Or can't enter the timer interrupt at all? Or is the timer interrupt's timing inaccurate?
This post is from MCU
 
 
 

63

Posts

0

Resources
5
 
First, take a look at the clock timing interrupt mode threshold initial value interrupt enable total interrupt interrupt vector
This post is from MCU
 
 
 

931

Posts

3

Resources
6
 
Interrupts should not be difficult to understand and easy to apply. There are many examples on the Internet. Just find a suitable code to transplant.
This post is from MCU
 
 
 

2865

Posts

4

Resources
7
 
Excuse me, do you know what "interruption" means?
This post is from MCU
 
 
 

1w

Posts

142

Resources
8
 
If you want to get timely and effective help, first learn to describe the problem correctly and completely.
This post is from MCU
 
Personal signature上传了一些书籍资料,也许有你想要的:http://download.eeworld.com.cn/user/chunyang
 
 

7171

Posts

195

Resources
9
 
When the timing time is reached, an interrupt is entered???
This post is from MCU
 
 
 

11

Posts

0

Resources
10
 
Thank you for your concern; Thank you all; I read it last night and understood that the timer counter is encapsulated inside and is dead. We just need to use it in the prescribed way. Then, now the problem comes again. The 12M clock runs at a maximum of 256US, and the frequency is only 3.9KHZ. I want to make a DA to control the power supply, which needs to be very stable and incremental.
This post is from MCU
 
 
 

11

Posts

0

Resources
11
 
There are many things to do after the New Year. I want to make a breakthrough at the end of the year; otherwise, I won’t be able to get through 2019.
This post is from MCU
 
 
 

931

Posts

3

Resources
12
 
The original poster is very stingy with words, why not provide more information? At least tell the model of the microcontroller, which timer you plan to use, and what purpose you want to achieve.
This post is from MCU
 
 
 

11

Posts

0

Resources
13
 
Hello, there is no MCU signal now. I simulated it on a PROTUES software, using the 51 core
This post is from MCU
 
 
 

11

Posts

0

Resources
14
 
See the attached picture

1.png (24.98 KB, downloads: 0)

1.png
This post is from MCU
 
 
 

11

Posts

0

Resources
15
 
#include
#include
sbit P1_7=P1^7 ; void main() { unsigned a; TMOD=0x00; TH0=0xE0; TL0=0x18; a=10; TR0=1; if(TF0==1) { if(a==0) P1_7=~P1_7; a--; TF0=0; } } The above is my code; timer 0 counts A=10 times, P1.7 port is inverted once; this loop
This post is from MCU
 
 
 

931

Posts

3

Resources
16
 
It seems that the host needs to flip the specified port regularly. It is recommended to use the 8-bit automatic filling timing mode. The timer can be configured through the microcontroller assistant software. In addition, there is no code for opening the general interrupt in your code, let alone the interrupt handling code.
This post is from MCU
 
 
 

11

Posts

0

Resources
17
 
hujj posted on 2019-2-2 19:10 It seems that the host needs to flip the specified port regularly. It is recommended to use the 8-bit automatic filling timing mode. The timer can be configured through the microcontroller assistant software. In addition...
Thank you, I optimized it again today and it is temporarily available. I will continue to work hard. Thank you everyone
This post is from MCU
 
 
 

11

Posts

0

Resources
18
 
#include
#include
sbit P1_7=P1^7; void main() { unsigned a=0; TMOD=0x01; TH0=0xE0; TL0=0x18; IT0=0; IT1=0; EA=1; EX0=1; EX1=1; TR0 =1; while(1) { if(TF0) { TF0=0; TH0=0xE0; TL0=0x18; a++; if(a==50) { P1_7=~P1_7; a=0; } } } } void buttom_0() interrupt 0 { _nop_(); _nop_(); _nop_(); _nop_(); if(P3^ 2==0) P0=0xff; } void buttom_1() interrupt 2 { _nop_(); _nop_(); _nop_(); _nop_(); if(P3^3==0) P0=0x00; }
This post is from MCU
 
 
 

11

Posts

0

Resources
19
 
The above is only for testing: 1. The timer controls the P1.7 port to flip the output; 2. The P0 port is interrupted by the rising edge of the external interrupt to control P0 to all 1 or 0;
This post is from MCU
 
 
 

11

Posts

0

Resources
20
 
However, my code has a while loop. Now it has fewer functions. If it has more functions, can I still use while? Is there a better way to solve the problem of multiple events at the same time?
This post is from MCU
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list