ATD Example

This implementation of the S12ATD10B8C module is suitable for a system requiring a single ATD channel only. Reads automatically kick off a new sequence of eight conversions of the defined channel with the result being the average of those eight conversions. The maximum rate for updated data is approximately 20KHz. The defines within the c file may conflict with the header file for your 9s12 variant.

Typical test:



// Note: printf is user defined
void main(void) {
  int retval, cur_data, prev_data;
  if((retval = atdStart()) != ATD_SUCCESS) {
    printf("Improper ATD pin definition!");
    while(1);
  }
  while(1) {
    retval = atdRead(&cur_data);
    if(retval == ATD_SUCCESS) {
      if(cur_data != prev_data) {
        printf("atd:0x%02x\r", cur_data);
        prev_data = cur_data;
      }
    }
  }
}

AttachmentSize
[file] atd.c6.95 KB
[file] atd.h1020 bytes