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:
//COMPARATOR PINS
//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);
CMP_DRV_Start(BOARD_CMP_INSTANCE);
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!
-Carlos
Hi,
Besides of above PTA0 pin MUX setting, it also need to change the <board.h> about BOARD_CMP_CHANNEL definition:
#define BOARD_CMP_CHANNEL | 2 |
The KL03 PTA0 pin is CMP0_IN2.
Wish it helps.
Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------