Post Go back to editing

How can I program the counter peripheral (CNT) as Push-button Operation?

Hi everyone,

I would like to configure the General-Purpose Counter (CNT) as "Zero Marker / push button support" in such a way that and interrupt service routine (ISR) is triggered with a rising edge of a square signal connected to the CNT1_ZM pin (PB_03 that corresponds to pin 38/74 of the expansion board).

I have followed the instructions of the "ADSP-CM40x Mixed-Signal Control Processor with ARM Cortex_M4 Hardware Reference (Preliminary Revision 0.2, September 2013)" sections: 

  - GP Counter General Programming Flow

  - Configuring GP Counter Push-Button Operation

I have declared a variable "a" inside the ISR that must be incremented every time the ISR is triggered, if I run the program the value of a is always 0. I connected a square signal of 850Hz to both: pin 38 and 74. It did not work.

Can someone check the code below? I am not sure if the ISR is properly coded.

I am testing the code with a ADSP CM403 board and the analog and digital expansions boards.

You will find attached a pdf with the problem description.

Thank you very much in advance.

The configuration of the peripheral is as follows:

*************************
*pREG_CNT1_CMD = BITM_CNT_CMD_W1LMAXZERO | BITM_CNT_CMD_W1LMINZERO | BITM_CNT_CMD_W1LCNTZERO |BITP_CNT_CMD_W1ZMONCE ;

*pREG_CNT1_IMSK = ENUM_CNT_IMSK_CZME_UMSK;

*pREG_CNT1_CFG = ENUM_CNT_CFG_NO_INPDIS | ENUM_CNT_CFG_CNTMODE_QUADENC | /* Enable input; Use quadrature counter mode */
ENUM_CNT_CFG_BNDMODE_BINENC | ENUM_CNT_CFG_ZMZC_DIS | /* Zero counter on ZM; ZM disabled (setting of BNDMODE has no effect) */
ENUM_CNT_CFG_CZMINV_AHI | /* Active high ZM (not used) */
ENUM_CNT_CFG_CUDINV_AHI | ENUM_CNT_CFG_CDGINV_AHI | /* Active high CUD and CDG */
ENUM_CNT_CFG_DEBDIS | ENUM_CNT_CFG_CNTDIS; /* Disable debounce; Disable counter */


adi_int_InstallHandler((IRQn_Type)INTR_CNT1_STAT, CNT1_STAT_ISR, 0, true);
NVIC_SetPriority((IRQn_Type)INTR_CNT1_STAT, 1); /* NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) */
NVIC_EnableIRQ((IRQn_Type)INTR_CNT1_STAT);

*************************

And the interrupt service routine:

*************************

void CNT1_STAT_ISR(uint32_t iid, void* handlerArg){
if (*pREG_CNT1_STAT &= BITM_CNT_IMSK_CZME){
*pREG_CNT1_STAT = 0x200;
a++;  // a should increment every time the ISR is triggered
}
}

*************************

CNT_query.pdf
  • Hi Yeni,

    Which revision of Hardware reference manual you are referring to? Please refer the latest revision of HRM.

    Looks like, you are enabling Zero marker error interrupt (CZME), instead of normal CZM pushbutton interrupt (CZM).

    Note that, in this case, when counter detects active edge on CZM pin, it compares the 4 LSB bits of CNTR with zero. If there is mismatch, it triggers the interrupt.

    So, please try CZM interrupt, as you mentioned.   

    Thanks,

    Prashant

  • Hi Prashant, 

    Thank you very much for your answer, I will try it!

    I am using currently this technical documentation:

      -  "ADSP-CM40x Mixed-Signal Control Processor with ARM Cortex_M4 Hardware Reference (Preliminary Revision 0.2,   September 2013)

     -  ADSP-CM403F EZ-KIT Schematic  (Revision 1.0, Date 08/27/2013)

    Can you point me where are newer versions of those documents (if available)?

    Regards,

    YVG