Microchip® Advanced Software Framework

sam0/applications/adc_configurations_example/main.c File Reference

SAMD21 ADC Configuration example.

Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.

#include <asf.h>
#include "conf_example.h"
#include "adc_configure.h"
#include "adc_temp.h"

Functions

void adc_calibration (void)
 ADC Calibration mode. More...
 
void adc_differential (void)
 ADC Differential mode. More...
 
void adc_hardware_averaging (void)
 ADC Hardware Averaging mode. More...
 
void adc_oversampling (void)
 ADC Oversampling mode. More...
 
uint16_t adc_start_read_result (void)
 ADC START and Read Result. More...
 
void adc_temp_sensor (void)
 ADC internal TemperatureSensor mode. More...
 
void adc_window_monitor (void)
 ADC Window Monitor mode. More...
 
void configure_console (void)
 Configure serial Console. More...
 
int main (void)
 

Variables

struct adc_module adc_instance
 Support and FAQ: visit Microchip Support More...
 
struct usart_module console_instance
 
uint16_t raw_result
 
float result
 
uint8_t status
 

void adc_calibration ( void  )

ADC Calibration mode.

This function enable/disable the ADC calibration based on the user input from serial console.

For offset calibration user has to connect GND(0V) on ADC input.

For Gain Calibration user has to connect 1.55V on ADC input.

Serial console prints the ADC input voltage after calibration done.

References adc_correction_start(), adc_correction_stop(), adc_start_read_result(), configure_adc(), delay_ms, key, printf, raw_result, and result.

Referenced by main().

void adc_differential ( void  )

ADC Differential mode.

This function configures the ADC as differential mode and converts the differential voltage applied on positive input and negative input. Prints the differential voltage on serial console and disable the ADC.

References adc_disable(), adc_instance, adc_start_read_result(), configure_adc_differential(), printf, raw_result, and result.

Referenced by main().

void adc_hardware_averaging ( void  )

ADC Hardware Averaging mode.

This function configures the ADC as hardware averaging mode and converts the ADC input applied on positive input then prints the ADC input voltage on serial console after hardware averaging done and disable the ADC

References adc_disable(), adc_instance, adc_start_read_result(), configure_adc_averaging(), printf, raw_result, and result.

Referenced by main().

void adc_oversampling ( void  )

ADC Oversampling mode.

This function configures the ADC with normal mode and oversampling feature and converts the ADC input applied on positive input. Prints the ADC input voltage for both mode on serial console to recognize the improvement.

References adc_disable(), adc_instance, adc_start_read_result(), configure_adc(), configure_adc_sampling(), printf, raw_result, and result.

Referenced by main().

uint16_t adc_start_read_result ( void  )

ADC START and Read Result.

This function starts the ADC and wait for the ADC conversation to be complete and read the ADC result register and return the same to calling function.

References adc_get_status(), adc_instance, adc_read(), adc_start_conversion(), and ADC_STATUS_RESULT_READY.

Referenced by adc_calibration(), adc_correction_start(), adc_differential(), adc_hardware_averaging(), adc_oversampling(), and adc_temp_sensor().

void adc_temp_sensor ( void  )

ADC internal TemperatureSensor mode.

This function enables the internal temperature sensor for ADC input and displays the current room temperature in serial console after the calculation done using ADC result.

References adc_start_read_result(), calculate_temperature(), configure_adc_temp(), load_calibration_data(), printf, raw_result, system_voltage_reference_enable(), and SYSTEM_VOLTAGE_REFERENCE_TEMPSENSE.

Referenced by main().

void adc_window_monitor ( void  )

ADC Window Monitor mode.

This function configures the ADC as window monitor mode and predefine the voltage level for monitoring. If the ADC input exceeds the voltage level the LED0 will be in ON state in SAMD21 Xplained Pro.

References adc_get_status(), adc_instance, adc_read(), adc_start_conversion(), ADC_STATUS_RESULT_READY, ADC_STATUS_WINDOW, configure_adc_window_monitor(), HIGH, LOW, port_pin_set_output_level(), printf, raw_result, and status.

Referenced by main().

void configure_console ( void  )

Configure serial Console.

This function configures and enable the SERCOM module with below Settings.

GLCK for SERCOM -> GCLK_GENERATOR_0 (8MHz) SERCOM instance -> 3 TXD -> PA22 RXD -> PA23 BAUDRATE -> 115200 STOP BIT -> 1 CHARACTER -> 8 PARITY -> NONE

References usart_config::baudrate, console_instance, usart_config::mux_setting, usart_config::pinmux_pad0, usart_config::pinmux_pad1, usart_config::pinmux_pad2, usart_config::pinmux_pad3, usart_enable(), and usart_get_config_defaults().

Referenced by main().

struct adc_module adc_instance

Support and FAQ: visit Microchip Support

Support and FAQ: visit Microchip Support

Support and FAQ: visit Microchip Support

[adc_module_inst]

Support and FAQ: visit Microchip Support

[module_inst]

struct usart_module console_instance

Referenced by configure_console().

float result
uint8_t status

Referenced by _at25dfx_chip_get_nonbusy_status(), _at25dfx_chip_issue_read_command_wait(), _at25dfx_chip_issue_write_command_wait(), AckStatusCallback(), adc_window_monitor(), adp_interface_read_response(), adp_interface_send(), anp_client_connected_state_handler(), anp_client_init(), anp_custom_event(), app_indication_confirmation_handler(), app_init(), app_notification_confirmation_handler(), app_read_response_cb(), at25dfx_chip_check_presence(), at25dfx_chip_erase(), at25dfx_chip_erase_block(), at25dfx_chip_get_sector_protect(), at25dfx_chip_read_buffer(), at25dfx_chip_set_global_sector_protect(), at25dfx_chip_set_sector_protect(), at25dfx_chip_sleep(), at25dfx_chip_wake(), at25dfx_chip_write_buffer(), at_app_send_lecb(), at_ble_addr_set(), at_ble_adv_start(), at_ble_att_error(), at_ble_authenticate(), at_ble_connect(), at_ble_disconnect(), at_ble_event_get(), at_ble_gap_error(), at_ble_init(), at_ble_scan_start(), bas_send_notification(), bat_char_changed_event(), bat_custom_event(), bat_update_char_value(), battery_service_advertise(), battery_set_advertisement_data(), battery_simulation_task(), battery_start_advertisement(), ble_advertisement_data_set(), ble_char_changed_app_event(), ble_check_device_state(), ble_connected_device_role(), ble_disconnected_app_event(), ble_disconnected_device_role(), ble_mgr_events_callback_handler(), ble_observer_custom_event(), ble_remove_bonding_info(), ble_restore_bonding_info(), ble_store_bonding_info(), ble_trans_char_changed_event(), blp_disconnection(), blp_sensor_adv(), blp_sensor_app_custom_event(), blp_sensor_init(), blp_sensor_send_indication(), blp_sensor_send_notification(), blp_sensor_service_define(), brd_adv_init(), brd_set_advertisement_data(), brd_start_broadcast(), buffered_uart_tx(), csc_prf_connected_state_handler(), csc_prf_init(), csc_serv_send_data(), dao_ack_input(), dbg_init(), dbg_le_get_bd_addr_req_handler(), dbg_le_set_bd_addr_req_handler(), dbg_rd_mem_req_handler(), dbg_rd_mem_req_handler32(), dbg_set_tx_pw_req_handler(), dbg_wr_mem_req_handler(), dbg_wr_mem_req_handler32(), dbg_wr_mem_req_handler32_reset(), device_information_advertise(), dis_custom_event(), dump_trx_register_values(), eddystone_adv_start(), eddystone_adv_stop(), eddystone_app_init(), eddystone_create_tlm_frame(), eddystone_create_url_frame(), eddystone_custom_event(), eddystone_set_beacon_interval(), eddystone_set_power_mode(), eddystone_tlm_frame_send(), eddystone_uid_frame_send(), eddystone_url_frame_send(), esurl_char_changed_event(), esurl_conf_adv_start(), esurl_conf_chars_reset(), esurl_conf_service_init(), esurl_write_authorize_event(), event_get(), fmp_custom_event(), fmp_locator_connected_state_handler(), fmp_locator_pair_done_handler(), fmp_locator_service_discover(), fmp_target_connected_state_handler(), gap_dev_scan(), gapc_bond_cfm_handler_key_exch(), gapc_bond_cfm_handler_pair_resp(), gapc_bond_cmd_handler(), gapc_cmp_evt(), gapc_connection_cfm_handler(), gapc_disconnect_cmd_handler(), gapc_encrypt_cfm_handler(), gapc_encrypt_cmd_handler(), gapc_get_info_cmd_handler(), gapc_get_tx_pwr_req_handler(), gapc_param_update_cfm_handler(), gapc_param_update_cmd_handler(), gapc_security_cmd_handler(), gapc_set_tx_pwr_req_handler(), gapm_cancel_cmd_handler(), gapm_connection_cfm_handler(), gapm_reset_req_handler(), gapm_resolv_addr_cmd_handler(), gapm_set_dev_config_cmd_handler(), gapm_set_dev_name_handler(), gapm_start_adv_cmd_handler(), gapm_start_connection_cmd_handler(), gapm_start_scan_cmd_handler(), gapm_white_list_mgm_cmd(), gattc_complete_evt_handler(), gattc_disc_cmd_handler(), gattc_execute_write_cmd_handler(), gattc_mtu_cmd_handler(), gattc_read_cmd_handler_by_uuid(), gattc_read_cmd_handler_multible(), gattc_read_cmd_handler_simple_read(), gattc_reg_to_peer_handler(), gattc_send_evt_cmd_handler(), gattc_svc_changed_notification_cmd_handler(), gattc_write_cmd_handler(), gattc_write_cmd_ind(), gattc_write_cmd_ind_handler(), hid_boot_keyboardreport_update(), hid_boot_mousereport_update(), hid_custom_event(), hid_get_reportchar(), hid_get_reportid(), hid_serv_report_update(), hid_service_dbreg(), hr_sensor_adv(), hr_sensor_app_custom_event(), hr_sensor_char_write_request(), hr_sensor_disconnect(), hr_sensor_init(), hr_sensor_send_notification(), hr_sensor_service_define(), htp_init(), htp_temperature_send(), htpt_custom_event(), htpt_set_advertisement_data(), i2c_master_lock(), i2c_slave_get_direction_wait(), i2c_slave_get_status(), i2c_slave_lock(), i2c_slave_read_packet_wait(), i2c_slave_write_packet_wait(), i2s_get_status(), init_storage(), interface_send_wait(), ksz8851snl_read(), ksz8851snl_update(), l2cap_custom_event(), m2m_ssl_cb(), mac_gen_mcps_data_conf(), mac_gen_mlme_gts_conf(), mac_process_tal_tx_status(), mac_reset(), main(), main_control_transfer_done(), main_iso_in_done(), main_iso_out_done(), main_transfer_done(), mem_read_capacity(), mem_test_unit_ready(), memory_2_ram(), memory_2_usb(), mlme_get(), mlme_reset_request(), mlme_set(), mlme_set_request(), multirole_app_custom_event(), nwkTxConfirm(), packet_sent(), pal_timer_get_id(), pal_timer_start(), pal_timer_stop(), parse_mpdu(), pas_client_char_read_response_handler(), pas_client_char_write_response_handler(), pas_client_discovery_complete_handler(), pas_client_init(), pas_client_write_notifications(), pas_custom_event(), pds_compact_sector(), pds_delete(), pds_delete_all(), pds_init(), pds_item_exist(), pds_list_item(), pds_module_init(), pds_nvm_erase(), pds_read(), pds_write(), peer_search_initiator_tx_done_cb(), per_mode_receptor_tx_done_cb(), PHY_TaskHandler(), platform_event_wait(), platform_init(), PROCESS_THREAD(), pxp_monitor_app_custom_event(), pxp_monitor_encryption_change_handler(), pxp_monitor_pair_done_handler(), pxp_monitor_service_discover(), pxp_monitor_service_found_handler(), pxp_reporter_connected_state_handler(), pxp_reporter_custom_event(), ram_2_memory(), rf212_sleep(), rf233_sleep(), rssi_update(), rtc_calendar_register_callback(), rtc_calendar_unregister_callback(), run_ac_init_test(), run_adc_init_test(), run_bod_init_test(), run_bod_test(), run_check_presence_test(), run_dac_event_control_test(), run_dac_init_test(), run_eeprom_buffer_read_write_test(), run_eeprom_init_test(), run_eeprom_page_read_write_test(), run_erase_block_test(), run_erase_test(), run_global_sector_protect_test(), run_i2c_full_speed_test(), run_i2c_init_test(), run_i2c_master_transfer_test(), run_nvm_erase_test(), run_nvm_init_test(), run_nvm_read_and_write_test(), run_nvm_update_test(), run_read_write_buffer_test(), run_rtc_calendar_interrupt_test(), run_rtc_calendar_test(), run_rtc_count_interrupt_test(), run_rtc_count_test(), run_set_get_sector_protect_test(), run_spi_init_test(), run_transceive_buffer_test(), send_reset_conf(), set_paramter_on_recptor_node(), set_tal_pib_internal(), setup_ac_callback_mode_test(), setup_ac_window_mode_test(), setup_adc_average_mode_test(), setup_adc_window_mode_test(), setup_transfer_9bit_test(), sio2host_tx(), sio2ncp_tx(), spi_get_job_status_wait(), spi_lock(), spi_master_vec_get_job_status_wait(), spi_master_vec_init(), spi_master_vec_lock(), spi_master_vec_transceive_buffer_wait(), sps_custom_event(), sps_service_advertise(), stream_mem_to_mem(), system_interrupt_clear_pending(), system_interrupt_set_pending(), system_interrupt_set_priority(), tal_tx_frame_done_cb(), tcc_get_status(), tcc_init(), tcc_set_double_buffer_compare_values(), tcc_set_double_buffer_top_values(), test_event_gen_user_init(), time_info_adv(), time_info_connected_state_handler(), tip_app_custom_event(), trans_update_ctrl_char_value(), trans_update_tx_char_value(), transceive_data(), tx_done_handling(), udi_msc_process_trans(), udi_msc_trans_ack(), usart_lock(), usb_2_memory(), usr_cont_pulse_tx_confirm(), usr_cont_wave_tx_confirm(), usr_ed_scan_start_confirm(), usr_get_current_config_confirm(), usr_identify_board_confirm(), usr_identify_peer_node_confirm(), usr_mcps_data_conf(), usr_mlme_gts_conf(), usr_mlme_reset_conf(), usr_mlme_set_conf(), usr_peer_disconnect_confirm(), usr_per_test_end_indication(), usr_per_test_start_confirm(), usr_perf_get_confirm(), usr_perf_set_confirm(), usr_perf_start_confirm(), usr_pkt_stream_confirm(), usr_range_test_start_confirm(), usr_range_test_stop_confirm(), usr_register_dump_confirm(), usr_register_read_confirm(), usr_register_write_confirm(), usr_rx_on_confirm(), usr_sensor_data_get_confirm(), usr_set_default_config_confirm(), wifi_provision_scanlist_receive(), wifiprov_disable(), wifiprov_scan_list_ind_send(), wifiprov_scan_mode_change_ind_send(), wifiprov_start(), and wifiprov_wifi_con_update().