1896 views|0 replies

1140

Posts

0

Resources
The OP
 

MSP430 interrupt mechanism [Copy link]

I am writing something about interrupts because of DC's invitation. I have only been in contact with 430 for a short time and can only share my own experience with you. Please forgive me if there are any omissions. I will not repeat the interrupt introduction in the MSP430 user manual. You can read the User Guider. I mainly talk about the things that are not in the book or are not clear enough. I hope it will be useful to you. 1. Interrupt nesting and priority The control bit of the 430 total interrupt is the GIE bit in the status register (this bit is in the SR register). When this bit is in the reset state, all maskable interrupts will not be responded. Maskable interrupts are divided into single interrupt source and multiple interrupt sources. For single interrupt source, the interrupt flag bit is automatically cleared after responding to the interrupt service program, while for multiple interrupt sources, the interrupt flag bit is cleared only after querying a certain register. Since the first microcontroller that most people come into contact with is usually 51, if a higher priority interrupt occurs when the 51 microcontroller CPU responds to a low priority interrupt program, the microcontroller will execute the high priority, and this process has already generated interrupt nesting. The 430 microcontroller is different. When responding to a low-priority interrupt service program, even if a higher-priority interrupt service request comes, the 430 will ignore it until the low-priority interrupt service program is executed, and then it will respond to the high-priority interrupt. This is because when the 430 responds to the interrupt program, the general interrupt GIE is in the reset state. If you want to generate interrupt nesting similar to 51, you can only set the GIE bit again in the interrupt function. 2. Timer TA TimerA has 2 interrupt vectors. TIMERA0, TIMERA1 TIMERA0 only counts for overflow of CCR0. After querying TAIV, you can know whether it is caused by CCR1, CCR2, or TAIFG. As for the situation in which TAIFG is set, it depends on the TA working mode. Please refer to the user manual. Another point is that TA itself has PWM output function, and there is no need to borrow the interrupt function. On this issue, the application detour often occurs in how to combine TA and AD to implement timing sampling. Many people open AD in the TA interrupt to do this. This is not appropriate, because the ADC10 and ADC12 (SD16 is not familiar, so I have no say) modules of 430 have pulse sampling mode and extended sampling mode. Just select AD to be sampled by TA, and then set TA to PWM output mode. Of course, the output PWM wave is a special function pin, but it is not needed here, so the pin setting does not need to be paid attention to. What is worth caring about is the frequency of PWM, that is, the sampling rate of your AD. 3. Watchdog reset The watchdog has two working modes: timer, watchdog timer working mode WDTIFG has a flag bit automatically reset in response to the interrupt service program, and in watchdog mode, the flag bit can only be cleared by software. But how to judge whether the reset is caused by the timer overflow of WDT working in watchdog mode, or the error of watchdog writing key? ……………………………… The answer is no way, at least I have not seen any way, nor have I seen any way around me. If anyone knows the method, thank you for sharing. 4. People often ask the function of this statement MOV.B #LPM0,0(SP). If you are in standby mode in LPM0 before entering the interrupt function, and you want to enter standby mode in LPM3 after executing the interrupt function, writing MOV.B #LPM3,SR in the interrupt function is invalid. Because when entering the interrupt, 430 will push PC and SR to the stack (SR stores the low power mode settings). Even if you write MOV.B #LPM3,SR, SR will be reset to low power 0 when exiting the interrupt stack. To achieve this goal, you can only change the SR setting in the stack: MOV.B #LPM0,0(SP). 5 Interrupt vector: The interrupt vector of 430 is FFE0H-FFFFH, a total of 32 bytes, which is the last segment of FLASH. The FLASH of 430 is large or small, but the last address is definitely FFFFH (except for large FLASH exceeding 64K), so their starting addresses are different. Generally, IAR defaults to compiling and putting the program at the beginning of FLASH (excluding the information segment). A question worth clarifying is: What is an interrupt vector? The interrupt vector is actually the storage unit space that stores the entry address of the interrupt function. Just like the two bytes FFFEH+FFFFH are the reset interrupt vector, it stores the starting address of the main function in the FLASH. If the main function is stored in the FLASH block with 0x1100 as the starting address, you will find that 0x11 is stored in FFFFH and 0x00 is stored in FFFE. Other TimerA, ADC12, all are the same. It's just that the length of the program you write each time is different, and the location of the interrupt function is different. The IAR compiler will set it for you, and then when you use JTAG to burn the program, burn this address to the corresponding interrupt vector. Because the address of the interrupt function can be customized by the user or automatically compiled by IAR, this address is unknown to others except the source code developer. BSL is the password set by the special content of the 32-byte interrupt vector. But there are a few things that are unchanged in 430, that is, after the conditions for triggering an interrupt are met, where it goes to address the entry address of the interrupt service function is fixed when TI makes 430. For example, when powering on and resetting, it knows to find the address in FFFE, FFFF units instead of FFE0, FFE2. This mapping relationship is fixed in 430. But sometimes you just need to change the "interrupt vector", what should you do? Sometimes you will encounter this problem in the 430FLASH program self-upgrade. The method is to make a jump operation in the original default interrupt vector table of 430. Take the power-on reset as an example: ORG 0x2345 PowerReset: mov.w &0xFCFE, PC ………………………… ………………………… ORG 0xFFFE DW PowerReset In this way, 0xFCFE is equivalent to the mapping of 0xFFFE. This is in the TI application report of the 430 program self-upgrade.

This post is from Microcontroller 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