IAR 4.1 и ISR проблема Сконфигурировал UART1 для генерации сообщений по U1THRE.
Но при отладке не вызывается обработчик ISR. Что тут может быть не правильно?
startup.s79
;--------------------------------------------------------------- ; Macros and definitions for the whole file ;--------------------------------------------------------------- MODE_BITS DEFINE 0x1F ; Bit mask for mode bits in CPSR USR_MODE DEFINE 0x10 ; User mode FIQ_MODE DEFINE 0x11 ; Fast Interrupt Request mode IRQ_MODE DEFINE 0x12 ; Interrupt Request mode SVC_MODE DEFINE 0x13 ; Supervisor mode ABT_MODE DEFINE 0x17 ; Abort mode UND_MODE DEFINE 0x1B ; Undefined Instruction mode SYS_MODE DEFINE 0x1F ; System mode MODULE ?RESET COMMON INTVEC:CODE:NOROOT(2) PUBLIC __program_start EXTERN ?cstartup EXTERN irq_handler CODE32 ; Always ARM mode after reset org 0x00 __program_start ldr pc,=?cstartup ; Absolute jump can reach 4 GByte org 0x04 undef_handler ldr pc,=undef_handler org 0x08 swi_handler ldr pc,=swi_handler org 0x0c prefetch_handler ldr pc,=prefetch_handler org 0x10 data_handler ldr pc,=data_handler org 0x18 ldr pc,=irq_handler org 0x1c fiq_handler ldr pc,=fiq_handler ; Constant table entries (for ldr pc) will be placed at 0x20 org 0x20 LTORG ENDMOD MODULE ?CSTARTUP RSEG IRQ_STACK:DATA(2) RSEG SVC_STACK:DATA:NOROOT(2) RSEG CSTACK:DATA(2) RSEG ICODE:CODE:NOROOT(2) PUBLIC ?cstartup EXTERN ?main CODE32 ?cstartup mrs r0,cpsr ; Original PSR value bic r0,r0,#MODE_BITS ; Clear the mode bits orr r0,r0,#IRQ_MODE ; Set IRQ mode bits msr cpsr_c,r0 ; Change the mode ldr sp,=SFE(IRQ_STACK) & 0xFFFFFFF8 ; End of IRQ_STACK bic r0,r0,#MODE_BITS ; Clear the mode bits orr r0,r0,#SYS_MODE ; Set System mode bits msr cpsr_c,r0 ; Change the mode ldr sp,=SFE(CSTACK) & 0xFFFFFFF8 ; End of CSTACK ldr r0,=?main bx r0 LTORG ENDMOD ENDmain.c
#include#include #include #include "iolpc210x.h" //XTAL frequency in Hz #define XTALFREQ 14745600 //pclk must always be XTALFREQ/4 when using the ROM monitor. #define PCLKFREQ (XTALFREQ/4) #define BAUDRATE 9600 #define BAUDRATEDIVISOR (PCLKFREQ/(BAUDRATE*16)) // IRQ exception handler. Calls the interrupt handlers. __irq __arm void irq_handler(void) { void (*interrupt_function)(); unsigned int vector; vector = VICVectAddr; // Get interrupt vector. interrupt_function = (void(*)())vector; (*interrupt_function)(); // Call vectored interrupt function. VICVectAddr = 0; // Clear interrupt in VIC. } //Dummy interrupt handler, called as default in irqHandler() if no other //vectored interrupt is called. static void DefDummyInterrupt() { } //UART1 interrupt handler static void UART1Interrupt() { } void main(void) { MEMMAP = 2; //Set pins for use with UART PINSEL0_bit.P0_8=0x1; // Set pin function to TxD (UART1) PINSEL0_bit.P0_9=0x1; // Set pin function to RxD (UART1) //Set the FIFO enable bit in the FCR register. This bit must be set for //proper UART operation. U1FCR_bit.FCRFE = 1; //Set baudrate U1LCR_bit.DLAB = 1; U1DLL = BAUDRATEDIVISOR & 0x00ff; U1DLM = (BAUDRATEDIVISOR >> 8) & 0x00ff; U1LCR_bit.DLAB = 0; //Set mode U1LCR_bit.WLS = 0x3; //8 bit word length U1LCR_bit.SBS = 0x0; //1 stop bit U1LCR_bit.PE = 0x0; //No parity //Enable UART1 interrupts U1IER_bit.RDAIE = 0; //Enable byte received interrupt U1IER_bit.THREIE = 1; //Enable tx buf empty interrupt __disable_interrupt(); // Setup interrupt controller. VICProtection = 0; VICIntEnClear = 0xffffffff; VICSoftIntClear = 0xffffffff; VICDefVectAddr = (unsigned int)&DefDummyInterrupt; VICIntSelect &= ~(1<
-
- Ответ: zigr(47 знак., 14.10.2004 14:13)
- Посмотрите в исходники для арм по ссылке - pin_л(14.10.2004 14:16, ссылка)
- Ответ: спасибо. полезные исходники. все заработало - zigr(14.10.2004 16:25)
- Посмотрите в исходники для арм по ссылке - pin_л(14.10.2004 14:16, ссылка)
- Ответ: zigr(47 знак., 14.10.2004 14:13)