
AN07-00200-03E
75
The flowcharts for the sample programs are shown in “Figure 4-11 Single-unit operation flowcharts”.
First, the ports, interrupt levels, external interrupts, and A/D converter are initialized. Thereafter, the
program enters a loop. Here, when SW2 is pressed, an external interrupt is created, and the LED
on/of processing is performed. Further, when SW3 is pressed, the buzzer is output. Here, the buzzer
sound can be changed by operating the Volume SW.
So, let us look at an actual program.
Check the following folder for the sample program. The folder contains several files. First, open
“main.c”.
¥bitpot_yellow_SampleProgram_single-chip¥single_operation¥source
Check around the line 37 as shown in “Figure 4-12 Operation mode settings (when using volume
switch)” to select the operation mode. #define is set, so that whether to use the temperature sensor,
and the enable/disable settings can be configured. To use the Volume SW for inputs to the A/D
converter, configure the settings as shown in Figure 4-14, and to use the temperature sensor,
configure the settings as shown in Figure 4-15.
In this explanation, the temperature sensor is not used, but use of the volume switch is enabled.
Figure 4-12 Operation mode settings (when using volume switch)
Figure 4-13 Operation mode settings (when using the temperature sensor)
Note: The operation mode settings must be configured not only for main.c, but also for ADC.c and
ext_int.c.
/* Temperature sensor use (1), or unused (0)
*/
#define TEMP_SENSOR_USE
(0)
/* Temperature measurement permission, non-permission */
#define TEMP_MEASURE_ON
(0)
#define TEMP_MEASURE_OFF
(1)
/* Temperature sensor use (1), or unused (0)
*/
#define TEMP_SENSOR_USE
(1)
/* Temperature measurement permission, non-permission */
#define TEMP_MEASURE_ON
(1)
#define TEMP_MEASURE_OFF
(0)
Temperature sensor disabled
Volume SW enabled
Temperature sensor not used
Temperature sensor used
Temperature sensor enabled
Volume switch disabled