⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 isr_lpc23xx.c

📁 Show Interworking of ARM/Thumb code on LPC23xx
💻 C
字号:
/*****************************************************************************
 *
 *      Project:    Clock Example
 *      Name:       Example
 *      Filename:   ISR_LPC23xx.c
 *      Date:       08.09.06
 *      Rights:     Hitex Development Tools
 *                  Greschbachstr. 12
 *                  76229  Karlsruhe
 *
 ****************************************************************************/

/******************************** module ISR_LPC.c **************************/

#define global extern   /* to declare external variables and functions      */

#include "defines.h"
#include "clock.h"
#include "lpc23xx.h"    /* LPC21XX Peripheral Registers                     */
#include "ISR_LPC23xx.h"
#include "LCD_LPC23xx.h"


extern unsigned long    _tc0_srv(void); 
extern void             _enableInterrupts(void);

extern unsigned long*    IRQ_Handler;

global void msec5_isr  (void);
global void init_isr   (void);
global void init_hw    (void);
global void controller_specific (uint8_t aData);
global void lcdout_HitexLogo(void);
global void lcdout_Question(void);

// write address to register macro
#define REG(addr) (*(volatile unsigned long *)(addr))

unsigned long           timeval;
static int              ledCounter;
static unsigned long    j;

/* Setup the Timer Counter 0 Interrupt */
void init_isr (void)
{
    int i;
    unsigned long*  aVectorAdr = (unsigned long*)(&VICVectAddr0);

    // the clock for timer in is 12 Mhz (main)
	TIMER0_PR  = 6;								// prescaler --> 2 Mhz
    TIMER0_MR0 = 10000;                         // counter value 
    TIMER0_MCR = 3;                             // Interrupt and Reset on MR0
    TIMER0_TCR = 1;                             // Timer0 Enable
    
    for(i=0; i<31; i++)
       *aVectorAdr++ = &IRQ_Handler;  // this is an endless loop

    aVectorAdr = (unsigned long*)(&VICVectAddr0); 
    *(aVectorAdr + 4) = (unsigned long)_tc0_srv;     // set interrupt vector in 0

    VICVectPriority4 = 0x04;                       // priority
    VICIntEnable = 0x00000010;                  // Enable Timer0 Interrupt

    _enableInterrupts();
}

void init_hw (void)
{
    ledCounter = 0x00;
    
    //  Clear PIN select function for ETM
    // using ETM set Bit 8
    
    PINSEL10  = 0x00; 

    FIOMASK2 = 0xFFFFFF00;
    FIODIR2 = 0xFF;              // P2.0..7 defined as Outputs 

    vLCDInit();                 // Initialize LCD display module 
  	vLCDCursorOff();
}

void led_on(uint32_t LEDno)
{
        FIOSET2 = LEDno;        /* Turn on LED */
}    
void led_off(uint32_t LEDno)
{
    FIOCLR2 = LEDno;          /* Turn off LED */
}    

void controller_specific (uint8_t aData)
{
    unsigned int j; 
    
    if( ledCounter == -1 )
      return;
      
    ledCounter++;
    if( (ledCounter % 125) == 0x00 )
    {
        j = ledCounter % 16;
        
        if( j > 8 )
            led_off(0x01 << (j & 0x7));
        else    
            led_on(0x01 << (j & 0x7));
       
    }          

    if( ledCounter == 4000 )
    {
       lcdout_HitexLogo();
    }
    if( ledCounter == 10000 )
    {
       lcdout_Question();
       ledCounter = 0x00; 
    }
}

void msec5_isr(void)
{
   inc_clock();                            /* clock increment  */
   convert_clock();                        /*   */
   signal_clock();                         /*   */
}

/* called from Interrupt service for timer tc0 */
void tc0_interrupt(void)
{
    setTimerPin(0x01);                  // set Port Pin 0.0
    
    msec5_isr();

    TIMER0_IR = 1;                      // Clear interrupt flag
    VICVectAddr = 0;                    // Acknowledge Interrupt

    clearTimerPin(0x01);                // clear Port Pin 0.1
}
/****************************************************************************
* Name:			lcdout_HitexLogo
*                  	
* Description:	writes a text to LCD
*						
* Parameters:	none
*					
* Return value:	none
****************************************************************************
*/
void lcdout_HitexLogo(void)
{
    vLCDCls ();
    vLCDPuts("Hitex Tools -   ");
    vLCDPuts("a good decision ");
}
 
/****************************************************************************
* Name:			lcdout_HitexLogo
*                  	
* Description:	writes a text to LCD
*						
* Parameters:	none
*					
* Return value:	none
****************************************************************************
*/
void lcdout_Question(void)
{
    vLCDCls ();
    vLCDPuts("Searching       ");
    vLCDPuts("debug tools ?   ");
} 

/************************************ EOF ***********************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -