Professional Documents
Culture Documents
Objective: To write a simple C program for ADC and test the same on the development board
Components Needed:
STM8AF Development Board, Connecting wires, LEDs
Software Needed:
IAR embedded workbench for STM8
Output: Output is seen using on board potentiometer and external LEDs which is connected to Port B.
C-Program
/* Includes ------------------------------------------------------------------*/
#include "stm8s.h"
/**
* @addtogroup ADC2_ContinuousConversion
* @{
*/
uint16_t Conversion_Value = 0;
/**
* @param None
* @retval None
Sy NO 5/3, 4TH Floor, Behind YES Bank ATM, Opp SKR Kalyana Mantapa, KundalahalliGate,
Marathahalli main road, Bangalore- 560037
PH: 9900 30 6000 / 080 2854 6010
*/
void main(void)
GPIO_Config();
ADC_Config();
ADC2_ITConfig(ENABLE);
enableInterrupts();
while (1)
/*Start Conversion */
ADC2_StartConversion();
GPIO_Write(GPIOB, Conversion_Value);
Delay((uint32_t)0xFFFF);
/**
* @param None
* @retval None
*/
ADC2_DeInit();
DISABLE);
/**
* @brief Configure GPIO for LEDs and buttons available on the evaluation board
* @param None
* @retval None
*/
}
Sy NO 5/3, 4TH Floor, Behind YES Bank ATM, Opp SKR Kalyana Mantapa, KundalahalliGate,
Marathahalli main road, Bangalore- 560037
PH: 9900 30 6000 / 080 2854 6010
/**
* @brief Delay.
* @param nCount
* @retval None
*/
while (nCount != 0)
nCount--;
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* @retval None
*/
/* User can add his own implementation to report the file name and line number,
while (1)
#endif
/**
* @}
*/
Sy NO 5/3, 4TH Floor, Behind YES Bank ATM, Opp SKR Kalyana Mantapa, KundalahalliGate,
Marathahalli main road, Bangalore- 560037
PH: 9900 30 6000 / 080 2854 6010