XMC 4700 ADC Boundary Check used to trigger Counter APP

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User12943
Level 1
Level 1
Hi,
I have an XMC 4700.
I have a 6kHz sine wave connected to P14.1.
I am using the ADC_MEASUREMENT_ADV app and the COUNTER_APP.

I would like to count the number of times the sine wave crosses zero. The zero offset is 2056U.

I have enabled the "generate boundary flag" in the app, set the lower and upper boundary to Group Boundary 0 and 1 respectively.

I have connected the "bound_fl_channel_A" to "counter_input".

I can not get the counter to detect a zero crossing. It appears that the ADC signal is continuously outside the boundary, regardless of where I set the boundary.
This is based on my investigation - the channel event is triggered every ADC conversion "If result outside band" is selected, regardless of boundary level.

I set the boundary with this command:
XMC_VADC_GROUP_SetBoundaries(GLOBAL_ADC_0.group_ptrs_array[ADC_MEASUREMENT_ADV_0.group_index]->group_handle, 0U, 2056U);


Does anyone have any ideas as to what I'm doing wrong?



I also have tried using the Event_Generator and Event_Detector apps and using an interrupt to increase a counter instead of the Counter APP but nothing has worked.

My configuration is as follows:

/********************************* Channel_A ADC Channel configuration structure ********************************/
static const XMC_VADC_CHANNEL_CONFIG_t ADC_MEASUREMENT_ADV_0_Channel_A_ch_config =
{
.input_class = (uint32_t) XMC_VADC_CHANNEL_CONV_GROUP_CLASS0,
.lower_boundary_select = (uint32_t) XMC_VADC_CHANNEL_BOUNDARY_GROUP_BOUND0,
.upper_boundary_select = (uint32_t) XMC_VADC_CHANNEL_BOUNDARY_GROUP_BOUND1,
.event_gen_criteria = (uint32_t) XMC_VADC_CHANNEL_EVGEN_INBOUND,
.sync_conversion = (uint32_t) false, /* Sync feature disabled*/
.alternate_reference = (uint32_t) XMC_VADC_CHANNEL_REF_INTREF, /* Internal reference selected */
.result_reg_number = (uint32_t) 0, /* GxRES[0] selected */
.result_alignment = (uint32_t) XMC_VADC_RESULT_ALIGN_RIGHT, /* Result alignment - Right Aligned*/
.broken_wire_detect_channel = (uint32_t) XMC_VADC_CHANNEL_BWDCH_VAGND, /* No Broken wire mode select*/
.broken_wire_detect = (uint32_t) false, /* No Broken wire detection*/
.invert_boundary_flag_ch0 = (uint32_t) false,
.invert_boundary_flag_ch1 = (uint32_t) false,
.invert_boundary_flag_ch2 = (uint32_t) false,
.invert_boundary_flag_ch3 = (uint32_t) false,
.flag_output_condition_ch0 = (uint32_t) false,
.flag_output_condition_ch1 = (uint32_t) false,
.flag_output_condition_ch2 = (uint32_t) false,
.flag_output_condition_ch3 = (uint32_t) false,
.boundary_flag_mode_ch0 = (uint32_t) 1,
.boundary_flag_mode_ch1 = (uint32_t) 0,
.boundary_flag_mode_ch2 = (uint32_t) 0,
.boundary_flag_mode_ch3 = (uint32_t) 0,
.channel_priority = (uint32_t) true, /* Highest Priority: 1 selected*/
.alias_channel = (int8_t) XMC_VADC_CHANNEL_ALIAS_CH1 /* Channel is Aliased*/
};


/*Channel_A Result configuration structure*/
static const XMC_VADC_RESULT_CONFIG_t ADC_MEASUREMENT_ADV_0_Channel_A_res_config =
{
.data_reduction_control = (uint32_t) 0,
.post_processing_mode = (uint32_t) XMC_VADC_DMM_REDUCTION_MODE,
.wait_for_read_mode = (uint32_t) false,
.part_of_fifo = (uint32_t) false , /* No FIFO */
.event_gen_enable = (uint32_t) false /* Disable Result event */
};

/* Channel_A ADC channel Handle */
const ADC_MEASUREMENT_ADV_CHANNEL_t ADC_MEASUREMENT_ADV_0_Channel_A_handle =
{
.ch_num = (uint8_t) 0,
.group_index = (uint8_t) 0,
.ch_handle = (XMC_VADC_CHANNEL_CONFIG_t*) &ADC_MEASUREMENT_ADV_0_Channel_A_ch_config,
.res_handle[0] = (XMC_VADC_RESULT_CONFIG_t*) &ADC_MEASUREMENT_ADV_0_Channel_A_res_config,
};


and for the Counter APP:
/************************************** PULSE_CNT *********************************************/
/* Event configuration for counter instance PULSE_CNT */
XMC_CCU4_SLICE_EVENT_CONFIG_t PULSE_CNT_event0_config =
{
.mapped_input = XMC_CCU4_SLICE_INPUT_H,
.edge = XMC_CCU4_SLICE_EVENT_EDGE_SENSITIVITY_FALLING_EDGE,
.level = XMC_CCU4_SLICE_EVENT_LEVEL_SENSITIVITY_ACTIVE_LOW,
.duration = XMC_CCU4_SLICE_EVENT_FILTER_DISABLED
};
/*Configuration structure for CCU4 Counter for PULSE_CNT */
COUNTER_CCU4_CONFIG_t PULSE_CNT_ccu4_config =
{
.global_handle = (GLOBAL_CCU4_t*) &GLOBAL_CCU4_0,
.kernel_ptr = (XMC_CCU4_MODULE_t*) (void*) CCU43_BASE,
.slice_ptr = (XMC_CCU4_SLICE_t*) (void*) CCU43_CC40,
.event0_config = (XMC_CCU4_SLICE_EVENT_CONFIG_t*) &PULSE_CNT_event0_config,
.count_dir_event_config = NULL,
.gating_event_config = NULL,
.shadow_mask = (uint32_t)XMC_CCU4_SHADOW_TRANSFER_SLICE_0,
.count_match_value = (uint16_t) 11840,
.countdir_event = XMC_CCU4_SLICE_EVENT_NONE,
.gating_event = XMC_CCU4_SLICE_EVENT_NONE,
.count_match_node_id = XMC_CCU4_SLICE_SR_ID_0,
.count_rollover_node_id = XMC_CCU4_SLICE_SR_ID_0,
.event_edge_det_node_id = XMC_CCU4_SLICE_SR_ID_0,
.event1_node_id = XMC_CCU4_SLICE_SR_ID_0,
.event2_node_id = XMC_CCU4_SLICE_SR_ID_0,
.state = COUNTER_STATUS_UNINITIALIZED,
.kernel_number = (uint8_t) 3,
.slice_number = (uint8_t) 0,
.intr_count_match = (bool) false,
.intr_count_rollover = (bool) false,
.intr_evt_edge_detect = (bool) false,
.intr_event1_detect = (bool) false,
.intr_event2_detect = (bool) false,
.init_start = (bool) true
};
0 Likes
2 Replies
User12943
Level 1
Level 1
I have managed to get something working that will be good enough for my applicacation. However I still can't get the Boundary Check to work correctly.

The working setup uses an autoscan low priority background request to continuously trigger an aliased ADC channel 0 in fast compare mode. Once a cycle, at a zero crossing an event is generated and is connected to the Counter APP via the Event Generator App.

Thanks,
Nick
0 Likes
User12943
Level 1
Level 1
One thing I am still having an issue with is getting the hysteresis band to work. Does anyone know how you would go about doing this? Does the XMC 4700 have hysteresis automatically or does it have to be defined in software?

In the reference manual on page 215 it says:
"In Fast Compare Mode, a boundary flag reflects the result of the comparisons, i.e. it will be set/cleared when the compared signal level is above the compare value, and will be cleared/set when the signal level is below the compare value. The delta values define ahysteresis band around the compare value."
However in "Infineon-VADC-XMC4000-AP32305-AN-v01_02-EN" it says:
"For the XMC4500 microcontroller, the hysteresis in Fast Compare Mode has to be defined by software. An application example is depicted below. Here, the DMA switches the comparison value from Result Register 0 (RES0) to Result Register 1 (RES1) and vice-versa. Each DMA switch is triggered by the channel event generated if the conversion result changes to either level, above or below the compare value."
No mention is given to the XMC4700 in that paper.
0 Likes