FAQ
- Microcontrollers /
- MCU Function application /
- SN8PCxx Series /
- Interrupt
-
.Why program can run into external INT0 interrupt program while FP00IEN has already been cleared?
SONIX 8-bit MCU interrupt is that once received P0.0 interrupt condition, it can always set the corresponding interrupt flag FP00IRQ, but whether can enter interrupt depends on FP00IEN(this is set for customers inquiries necessary). However, if interrupt flag FP00IRQ is set by external interrupt conditions, at the same time, some other interrupt occurs, if interrupt service routine handled improperly, this may cause an error into the INT0 interrupt. Solution:
1. If there is no INT0 interrupt need in program, do not check FP00IRQ flag.
2. If the program requires INT0 interrupt, it should be used together with FP00IEN flag, as follows:B0BTS1 FP00IEN ; check whether P00 interrupt is enabled or not JMP EXIT ; No P00 interrupt,exit B0BTS1 P00IRQ ; Check other interrupt request flag JMP NEXT : NEXT: ; P00 interrupt service routine : EXIT: ; Exit interrupt service routine RETI -
.Why chips can not enter interrupt?
-
.P00 settings completely correct, why can not enter interrupt?
First, make sure P00 interrupt settings are correct, such as P00IEN is set to 1, PEDGE register settings are correct (edge trigger control mode). If the above settings has no problem, then check whether TC0 or TC1 counter is being used in program or generates interrupt, if so, please confirm TC1 or TC0 clock source is selected as Fcpu, and could not select TC1 or TC0 clock source as external P00 port, or when P00 port is triggered, TC0 or TC1 counter will add 1, but P00IRQ will not set to 1, thus P00 can not enter interrupt service routine. -
.Does SONIX MCU have interrupt priorities? How to set?
SONIX MCU hardware does not have interrupt priorities. However, in application, there may require interrupt priority, user can achieve it according to SONIX MCU characteristics by software.
For each interrupt Priority settings, and the system determine whether response interrupt request according to the state of IEN and IRQ. Users must check the interrupt control bits and interrupt request flag bits in interrupt vector, so the higher priority interrupt control bits and interrupt request flag bits can be set in the front for check.
For example:ISR: ;------------Save ACC-------------------------- b0xch A,AccBuf ; B0xch instruction do not change C,Z flag b0mov A,PFLAG B0MOV PflagBuf,A ;---------interrupt first------------------------- INT0CHK: B0BTS1 FT0IEN JMP INTTC0CHK B0BTS0 FT0IRQ JMP INTT0 INTTC0CHK: ; Check TC0 interrupt request B0BTS1 FTC0IEN ; Check TC0IEN JMP ISR90 ; Jump to exit of IRQ B0BTS0 FTC0IRQ ; Check TC0IRQ JMP INTTC0 ; Jump to TC0 interrupt service routine ;-------------exit interrupt------------------------- ISR90: B0MOV A, PflagBuf B0MOV PFLAG,A ; Restore the PFlag B0XCH A,AccBuf ; Restore the Reg. A ; B0xch instruction do not change C,Z flag RETI ; Exit the interrupt routine ;---------------------t0----------------------------- INTT0: B0BCLR FT0IRQ INTT090: JMP ISR90 ;---------------------tc0----------------------------- INTTC0: B0BCLR FTC0IRQ INTTC090: JMP ISR90 -
.Program can not enter interrupt routine, what aspects need to check?
Users need to check the following aspects:
1. Check whether the global interrupt control bit FGIE is enabled;
2. Check whether the corresponding interrupt request control bit is enabled;
3. Check whether there is interrupt occurred in program, such as the timer can overflow from the initialization settings; To generate an external interrupt, whether P0, P1 corresponding I/O port be set to input mode and there are level changes. -
.Can "Call" instruction be executed in Interrupt Service Routine?
Because of sonix MCU Stack number limitations, users should pay special attention to when execute Call in interrupt, if Stack is full when entering Interrupt, thus will cause Stack overflow, causing the program can not return. Therefore, if use Call in Interrupt, user must consider the worst-case Stack using number, be sure there is Interrupt Stack space when enter worst conditions.
- Microcontrollers /
- MCU Function application /
- SN8PCxx Series /
- Interrupt