QEI IRQ enabling with LPCOpen

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

QEI IRQ enabling with LPCOpen

360 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rabbi_jaccob on Thu Jul 10 08:13:13 MST 2014
Hello,

I'm using a LPC1768 in an own maked board.
I'm trying to use QEI and espacially, the interuption linked to the QEI.

The QEI works. It counts well the pulse. The velocity function with the timer is ok.

I implement this code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "sys_config.h" 
//#include "LPC17xx.h" 
//#include "system_LPC17xx.h" 
  
#include "board.h" 
#include "arch\lpc_arch.h" 
  
#ifndef _WINDOWS 
  #include "BSP.h" 
#endif 
//#include "GUI.h" 
#include "string.h" 
  
  
//Interruption du QEI 
void QEI_IRQHandler() 
{ 
    Board_LED_Set(0,Board_LED_Test(0)); 
    LPC_QEI->CLR=0; 
  
}; 
  
  
  
static void prvSetupHardware(void) 
{    
      
    /* LED0 is used for the link status, on = PHY cable detected */
    Board_Init(); 
      
    //Définir la broche P1.23 comme point B du QEI 
    Chip_GPIO_WriteDirBit(LPC_GPIO, 0x1, 0x14, false); 
    Chip_IOCON_PinMux(LPC_IOCON,0x1,0x14,  IOCON_MODE_PULLDOWN ,IOCON_FUNC1); 
    Chip_GPIO_WriteDirBit(LPC_GPIO, 0x1, 0x17, false); 
    Chip_IOCON_PinMux(LPC_IOCON,0x1,0x17,  IOCON_MODE_PULLDOWN ,IOCON_FUNC1); 
    Chip_GPIO_WriteDirBit(LPC_GPIO, 0x1, 0x18, false); 
    Chip_IOCON_PinMux(LPC_IOCON,0x1,0x18,  IOCON_MODE_PULLDOWN ,IOCON_FUNC1); 
      
    //Activer l'horloge du QEI 
    Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_QEI); 
    Chip_Clock_SetPCLKDiv(SYSCTL_PCLK_QEI, SYSCTL_CLKDIV_4); 
      
    //Config du QEI en comptage simple sur la voie B 
    LPC_QEI->CONF=6; 
      
    //Définition du calcul de vitesse 
    LPC_QEI->LOAD=(uint32_t)3000000; 
    LPC_QEI->MAXPOS=250000; 
      
    //Filtrage du QEI 
    LPC_QEI->FILTERPHB=10; 
      
    //Reset du QEI 
    LPC_QEI->CON=15; 
      
    //Préparation de l'interruption de la vitesse 
    //Autorisation de l'interruption uniquement sur overflow timer vitesse 
    LPC_QEI->IES=1; 
    NVIC_SetPriority((IRQn_Type) QEI_IRQn, 2); 
    NVIC_EnableIRQ((IRQn_Type) QEI_IRQn); 
      
} 
  
/***************************************************************************** 
 * Public functions 
 ****************************************************************************/
  
/** 
 * @brief   main routine for example_lwip_tcpecho_sa_17xx40xx 
 * @return  Function should not exit. 
 */
int main(void) 
{ 
    char test[20]={'d','e','b','u','t','\n','\0'}; 
    prvSetupHardware(); 
      
    //Test de l'UART 
    Board_UARTPutSTR(test); 
    //MainTask(); 
      
  while(1) { 
          
        msDelay(1000); 
        sprintf(test,"INTSTAT : %u\n",LPC_QEI->INTSTAT); 
        Board_UARTPutSTR(test); 
        sprintf(test,"VEL : %u\n",LPC_QEI->CAP); 
        Board_UARTPutSTR(test); 
        sprintf(test,"IE : %d\n",LPC_QEI->IE); 
        Board_UARTPutSTR(test); 
        Board_UARTPutChar('\n'); 
          
  } 
} 


In the main loop, the value of QEI register display good values.

Nevertheless, the handler implemented at the begining of my code is not executed.
Normally, the code :
LPC_QEI->IES=1; 
    NVIC_SetPriority((IRQn_Type) QEI_IRQn, 2); 
    NVIC_EnableIRQ((IRQn_Type) QEI_IRQn); 

enables QEI interruption for the velocity timer overflow and the CMSIS function should enable the interuption.

Why the interruption does'nt occur until the register display that overflow occur.
Labels (1)
0 Kudos
0 Replies