STM8 cannot jump out of TIM2 update interrupt

Publisher:rockstar6Latest update time:2020-03-06 Source: eefocusKeywords:STM8  TIM2  interrupt Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

I just learned STM8 and recorded how to solve the problems that occurred during debugging.


The chip used is STM8S103F3P6. I am going to make a card swiping module, in which the delay function is implemented with the tim2 timer. In the routines downloaded from the Internet, the delay function unit is 1ms. I think the interval time is a bit long, so I am going to change it to 10us, use the HSE external crystal oscillator 8MHz, 8 division, count 10 numbers to generate update interrupts. Then make a ms delay function, and implement 100 10us delay functions.


Problem phenomenon:

During the running process, it was found that after timer2 was initialized and the interrupt function enableinterrupts was turned on, the program could not jump out.


Problem analysis steps:

1. I debugged it first and found that the program could not jump out of the interrupt service function of tim2. At first, I thought that the code for clearing the interrupt flag was not executed, or that the code for clearing the interrupt flag should be executed immediately after entering the interrupt service function. I moved the code to the first sentence in the interrupt service function and ran it again, but it still did not work.


2. Open the register display window, refer to the Chinese manual of stm8s, find the register related content of tim2, debug in single step, and find that the clear interrupt bit of TIM2->SR1 is set to 0, but it will be set to 1 again after a few steps. I first analyzed that it might be a problem in a certain code, but after restarting four or five times, I found that the timing of setting to 1 is not fixed. Only then did I notice the CNTRL register. It seems that SR1 is set to 1 every time the value of this register becomes 0x09. Only then did I react that it might be that during the processing of the interrupt service function of tim2, another update interrupt came in and reset the update interrupt bit of SR1 to 1, which means that the timing of my tim2 is too short.


problem solved:

After extending the update time of the timer (100us), the problem was solved.


Summarize:

During the debugging process, I discovered the power of checking registers, which is a way to solve problems faster. When I used stm32 before, due to the rich online resources, basically any kind of problem could be searched. At the beginning, I also learned the library function version, so I didn’t use register debugging much, and mostly used the watch window to check the variable value. However, there are fewer online resources for stm8, and more of it needs to be done by yourself, which reflects the advantage of checking register values. It took about three hours from discovering the problem to solving it.

Keywords:STM8  TIM2  interrupt Reference address:STM8 cannot jump out of TIM2 update interrupt

Previous article:STM8L052 timer 1 configuration 30S
Next article:ST official library function GPIO port read and write function

Recommended ReadingLatest update time:2024-11-16 15:54

STM8的wait for interrupt
If I wrap wait forinterrupt(WFI) with disable interrupt and enable interrupt, do you think WFI can still be woken up? Have you ever thought about it? Last night I took the STM8L151K4 development board and tested it. This usage is completely fine. From this, I guess that inside the chip, the core should have a dedica
[Microcontroller]
STM8的wait for interrupt
IAR debugging stm8 optimization settings
I originally wanted to use the debug function of IAR to debug the stm8 board through st-link and check the value of the variable. However, I couldn’t see any change in the result and it kept showing unavailable. I was wondering what the hell was going on?  There was no other way but to search online, and I found that
[Microcontroller]
STM8 MCU internal storage EEPROM byte reading and writing example analysis
EEPROM (Electrically Erasable Programmable Read-Only Memory) is an electrically erasable programmable read-only memory.  It is a memory that can be electrically erased and written online, and the data will not be lost after power failure. It is widely used in embedded systems.  It generally stores user data in applica
[Microcontroller]
STM8 study notes---timer TIM4 function implementation
The TIM4 and TIM6 of the STM8 microcontroller are 8-bit basic timers. The timer functions are as follows: The functions of basic timers are relatively simple and are generally only used to implement timing functions. The basic timer also has relatively few registers. Timer 4 is used for testing here, and the TIM4
[Microcontroller]
STM8 study notes---timer TIM4 function implementation
Design of RTC clock of STM8 single chip microcomputer
The STM8 rtc clock can use an internal low-frequency clock source or an external low-speed 32768Hz clock source. The rtc code is as follows: #include #include voidinit_rtc(void) { RTC_InitTypeDefRTC_InitStr; RTC_TimeTypeDefRTC_TImeStr; RTC_DateTypeDefRTC_DateStr; #if0 /*LSI*/ CLK_RTCClockConfig(CLK_RTCCLKSource_L
[Microcontroller]
Design of RTC clock of STM8 single chip microcomputer
STM8 data @near @tiny definition
I can't remember this: stm8 stvd xdata near equals 51 tiny equals idata 51   http://www.waveshare.net/article/STM8-3-1-10.htm   How to assign a variable to a specific address Example: unsigned char temp_A@0x00; //define unsigned variable temp_A and force its address to be 0x00 unsigned char temp_B@0x100;
[Microcontroller]
Contiki clock module
一、functions for handling system time clock_time_t clock_time(void);//return the current system time in clock ticks unsigned long clock_seconds(void);//return the system time in seconds void clock_set_seconds(unsigned long ec);//set the value of the platform seconds These functions are platform dependent, and we impl
[Microcontroller]
STM8 interrupt controller ITC
Introduction         The interrupt controller provides the following functions:  ● Hardware interrupt management─  All I/O pins have external interrupt capability, and each port has an independent interrupt vector and independent flag.  ─ Peripheral interrupt capability  ● Software interrupt management (TRAP)  ●
[Microcontroller]
STM8 interrupt controller ITC
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号