AnsweredAssumed Answered

PTA0/CMP0_IN2 input to comparator on KL03

Question asked by CARLOS OTERO on Jul 15, 2015
Latest reply on Jul 15, 2015 by Hui_Ma

Hello dear Freescale community,


I am having trouble using PTA0 as CMP0_IN2 to the comparator to the input of the comparator.


As far as I see, my program works fine: if I use PTB5/COMP0_IN1, then everything runs fine, however I want to change from PTB5 to PTA0 since I don't want to mess with the NMI.  if it is any useful, I am using the 16QFN package.


This is how my GPIO configuration looks:


    //Pin PTA0 as comparator (cmp0_in2 --  ALT0)

    //Pin PTB1 as comparator (cmp0_in3 -- default, ALT0 --- No need to configure, but just to be safe.

    PORT_HAL_SetPullCmd(PORTB_BASE_PTR, 1u, false);

    PORT_HAL_SetPullCmd(PORTA_BASE_PTR, 0u, false);


    PORT_HAL_SetMuxMode(PORTB_BASE_PTR, 1u, kPortPinDisabled);

    PORT_HAL_SetMuxMode(PORTA_BASE_PTR, 0u, kPortPinDisabled);


    PORT_HAL_SetPullCmd(PORTA_BASE_PTR, 2u, false);

    PORT_HAL_SetMuxMode(PORTA_BASE_PTR, 2u,kPortMuxAlt2);



For the comparator, I am using the driver. and this is how my configuration looks like:


cmp_comparator_config_t comp_config_struct = {

    .hystersisMode = kCmpHystersisOfLevel3,

    .pinoutEnable = true,

    .pinoutUnfilteredEnable = true,

    .invertEnable = false,

    .highSpeedEnable = true,

    .risingIntEnable = false,

    .fallingIntEnable = false,

    .triggerEnable = false,

    //.minusChnMux = kCmpInputChn1,  //CMP0_1 is located in PTB5

    .minusChnMux = kCmpInputChn2, //CMP0_2 is located in PTA0

    .plusChnMux = kCmpInputChn3,   //CMP0_3 is located in PTB1



Then I just start the comparator like this:

   assert( CMP_DRV_Init(BOARD_CMP_INSTANCE, &comp_state, &comp_config_struct) ==  kStatus_CMP_Success);




Debugging is of course a pain since PTA0 uses SWD_CLK, so  as soon as I reach that point, I loose debugging capabilities.


Any advice would be really appreciated.


Thank you in advance!