Listing
1—Don’t try to run this code: it is a partial listing that should be regarded
for example only. You can get the real thing from the Circuit Cellar ftp site.
This example is intended to show you how little I had to do to get ADC clicks
from the Z8-based EVM to the Tera Term Pro terminal session.
// ** Before a line indicates added or changed code in the original Z8 example code.
** #define ISRC 0x00
** #define E1 0x01
** #define E2 0x02
** #define E3 0x03
** #define E4 0x04
** #define E5 0x05
** #define E6 0x06
** #define E7 0x07
** #define E8 0x08
** #define E9 0x09
** #define REFA 0x0A
** #define REFB 0x0B
** #define IOSC 0x0C
** #define ROSC 0x0D
** #define IGND 0x0E
** #define esc 0x1B
** unsigned char p_counter;
** void cls(void);
** void vthome(void);
********************************************************************
** void vthome(void)
** {
** printf("%c[f",esc);
** }
********************************************************************
** void cls(void)
** {
** printf("%c[2J",esc);
** }
********************************************************************
void print_data_continuous(void)
{
** cls();
** vthome();
** PFOUT = 1;
** p_counter = 0;
while(1)
{
if(data_ready ==0x01)
{
** if(++PFOUT == 0x0C)
** PFOUT = E1;
data_ready=0x00;
DI();
DACTL &= 0x0F;
read_all_channels(no_of_channels);
** display_data_new();
DACTL |= 0xC0;
EI();
}
}
}
********************************************************************
void display_data_new(void)
{
unsigned int temp;
** temp=store_adc_value[2];
** printf ("%4d\r\n", temp);
** if(++p_counter == 0x0B)
** {
** p_counter = 0;
** PFOUT = 1;
** vthome();
}
}
********************************************************************
main()
{
** PFADDR = 0x01; //Set port F data direction
** PFCTL = 0x00; //All outputs on Port F
** ADCCTL |= 0x20; //Activate external VREF
** no_of_channels = 0x02; //Access ADC channels 0 to 2
init_uart(); //Initialize UART for Tera Term Pro communication
** DMA_ADC_Test();
** init_dma_adc(1,no_of_channels);
** with_intr_start_dmaadc(); //Continues with interrupt
** print_data_continuous();
}