ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Суббота
18 мая
38797 Топик полностью
dmyl (09.09.2005 09:22, просмотров: 1) ответил Romario на покажте весь код инициализации железа только обрамите в теги
DefDummyInterrupt и прерывание таймера возникают по очереди друг за другом. Весь код тестовой программы. LED мигает, вроде бы все работет, но DefDummyInterrupt постоянно возникает. Этот же кусок в программе вообще не работает как положенно, что происходит не понятно такое впечатление что программа постоянно запускается как со сброса <pre> #include "iolpc2138.h" #include <inarm.h> int OOD; // Инициализация таймера void init_timer(void) { //******************* TIMER 1 // Clear interrupts flags T1IR=0xFF; // Disable counting T1TCR=0; // Clear timer counter T1TC=0; // Reset Compare modules T1MCR=0; T1MR0=0; T1MR1=0; T1MR2=0; T1MR3=0; // Reset Capture modules T1CCR=0; // Reset External Compare module T1EMR=0; T1PR=1000; // Timer 1 Prescaler T1PC=0; // Clear prescaler timer counter T1MCR=0x3; // Imterrupt and reset on MATCH0 T1MR0=15000; T1TCR=0x3; // Timer 1 enable and reset T1TCR=0x02; // Timer 1 reset T1TCR=0x01; // Timer 1 enable } //************************************************************ // LED void LED_OOD(int L) { if (L==0) IO0CLR_bit.P0_18=1; else IO0SET_bit.P0_18=1; } void init_GPIO(void) { PINSEL1_bit.P0_18=0; // ООД IO0DIR_bit.P0_18=1; IO0CLR_bit.P0_18=1; } //************************************************************ // Interrupt handlers. //************************************************************ //Dummy interrupt handler, called as default in irqHandler() if no other //vectored interrupt is called. static void DefDummyInterrupt(void) {} // Timer1 interrupt handler __irq void Timer1Interrupt(void) { if (OOD==0) OOD=1; else OOD=0; LED_OOD(OOD); // send_bipuls(); // Call timer callback function. T1IR = 0xff; // Clear timer 0 interrupt line. VICVectAddr = 0; // Clear interrupt in VIC. } // IRQ exception handler. Calls the interrupt handlers. #pragma vector=0x18 __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. } //************************************************************ void init_IRQ(void) { // Setup interrupt controller. VICProtection = 0; // Disable all interrupts VICIntEnClear = 0xffffffff; VICDefVectAddr = (unsigned int)&DefDummyInterrupt; // Setup timer callback function. VICIntSelect=0x0; // Timer 0&1 select as IRQ. VICVectAddr0 = (unsigned int)&Timer1Interrupt; VICVectCntl0 = 0x20 | VIC_TIMER1; // Enable vector interrupt for timer 1. VICIntEnable = 0x20; // Enable timer 0&1 interrupt. } //************************************************************ void init_PLL(void) { PLLCFG=0x00000024; // Кварц 12МГц, на выходе 60МГц PLLCON=0x00000001; // Разрешить PLL PLLFEED=0xAA; // Применить установки PLL PLLFEED=0x55; while (!(PLLSTAT&0x400));// Ожидаем захвата PLL PLLCON=0x00000003; // Подключить PLL PLLFEED=0xAA; // Применить установки PLL PLLFEED=0x55; VPBDIV=0; } //************************************************************ void main(void) { init_PLL(); __disable_interrupt(); // First disable interrupts. init_timer(); init_GPIO(); init_IRQ(); __enable_interrupt(); // Enable interrupts. for (;;); } </pre>