diff --git a/ports/psoc6/modules/machine/machine_adcblock.c b/ports/psoc6/modules/machine/machine_adcblock.c index 8f41ab6d6bfe..76ece0a9f18a 100644 --- a/ports/psoc6/modules/machine/machine_adcblock.c +++ b/ports/psoc6/modules/machine/machine_adcblock.c @@ -238,8 +238,10 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_adcblock_connect_obj, 2, machine_adcbl void adcblock_deinit(void) { for (uint8_t i = 0; i < MAX_BLOCKS; i++) { - cyhal_adc_free(&adc_block[i]->adc_block_obj); - adc_block[i] = NULL; + if (adc_block[i] != NULL) { + cyhal_adc_free(&adc_block[i]->adc_block_obj); + adc_block[i] = NULL; + } } }