/***************************************************************************************************
                          uint8_t SD_Init(uint8_t *cardType)
 ****************************************************************************************************
 * I/P Arguments :
                 uint8_t *: Pointer to stire Card Type
                           SDCARD_TYPE_UNKNOWN
                           SDCARD_TYPE_STANDARD
                           SDCARD_TYPE_HIGH_CAPACITY

 * Return value  :
                  uint8_t : Returns the SD card initialization status.
                  SDCARD_INIT_SUCCESSFUL
                  SDCARD_NOT_DETECTED
                  SDCARD_INIT_FAILED
                  SDCARD_FAT_INVALID

 * description :
                 This function is used to initialize the SD card.
                 It returns the initialization status as mentioned above.
 ****************************************************************************************************/
uint8_t SD_Init(uint8_t *cardType)
{
    uint8_t response,retry=0;

    SPI_Init();

    do{
        response = init_SdCard(cardType);
        retry++;
    }while((response != SDCARD_INIT_SUCCESSFUL) && (retry!=10) );


    if(response == SDCARD_INIT_SUCCESSFUL)
    {
        response = getBootSectorData (); //read boot sector and keep necessary data in global variables
    }

    return response;
}
Beispiel #2
0
//**************************************************************
// ****** MAIN FUNCTION FOR MIDI PROJECT ***********************
//**************************************************************
//Controller: ATmega644 (Clock: 8 Mhz-internal)
//Compiler: AVR-GCC (Ubuntu cross-compiler avr-g++ -v4.8.2)
//**************************************************************


#define F_CPU 8000000UL
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include "SPI_routines.h"
#include "SD_routines.h"
#include "FAT32.h"
#include "LCD_driver.h"
#include "menucontrol.h"

const unsigned char sdcardtesting[] PROGMEM ="  SD Card Testing..  ";
const unsigned char sdcardnotdectect[] PROGMEM ="SD card not detected..";
const unsigned char initilfail[] PROGMEM ="Card Initialization failed..";
const unsigned char sdv1_1[] PROGMEM ="Standard Capacity Card";
const unsigned char sdv1_2[] PROGMEM ="(Ver 1.x) Detected!";
const unsigned char sdhc_1[] PROGMEM ="High Capacity Card";
const unsigned char sdhc_2[] PROGMEM ="Detected!";
const unsigned char sdv2_1[] PROGMEM ="Standard Capacity Card";
const unsigned char sdv2_2[] PROGMEM ="(Ver 2.x) Detected!";
const unsigned char unknown_1[] PROGMEM ="Unknown SD Card Detected";
const unsigned char unknown_2[] PROGMEM ="Press OK key to continue";
const unsigned char fat32notfound[] PROGMEM ="FAT32 not found!";

//***********************************************************************************/
//call this routine to initialize LCD and SPI for SD card							 /
//***********************************************************************************/
void init_devices(void)
{
  cli();  //all interrupts disabled
  LCD_init();
  spi_init();
  MCUCR = 0x00;
 TIMSK1 = 0x00; //timer interrupt sources
}

//***********************************************************************************/
//Function: the whole project access point 											 /
//***********************************************************************************/
int main(void)
{
  unsigned char error, FAT32_active;
  unsigned int i;
  unsigned char fileName[13];
  
  init_devices();
  
 begining:

  LCD_command(CLEARSCR);
  LCD_command(FIRST_ROW_START);
  printf_strPGM((PGM_P)sdcardtesting);
  
  cardType = 0;

  for (i=0; i<10; i++)
    {
      error = SD_init();
      if(!error) break;
    }
  
  if(error)
    {
      LCD_command(CLEARSCR);
      LCD_command(FIRST_ROW_START);
      if(error == 1) printf_strPGM((PGM_P)sdcardnotdectect);
      if(error == 2) printf_strPGM((PGM_P)initilfail);
      LCD_command(SECOND_ROW_START);
      printf_strDM((unsigned char*)"Press CONFIRM to recheck");
      while(1) //press confirm to continue
	{
	  if(PINA==0xdf)
	    {
	      while(PINA!=0xff);
	      
	      goto begining; //retesting for SD card initialization
	    }
	}
    }
  
  switch (cardType)
    {
    case 1:
      display_continue((PGM_P)sdv1_1,(PGM_P)sdv1_2);
      //printf_str("Standard Capacity Card (Ver 1.x) Detected!");
      break;
    case 2:
      display_continue((PGM_P)(sdhc_1), (PGM_P)(sdhc_2));
      //printf_str("High Capacity Card Detected!");
      break;
    case 3:
      display_continue((PGM_P)(sdv2_1),(PGM_P)(sdv2_2));
      //printf_str("Standard Capacity Card (Ver 2.x) Detected!");
      break;
    default:display_continue((PGM_P)(unknown_1),(PGM_P)(unknown_2));
      break; 
    }
    
  SPI_HIGH_SPEED;	//SCK - 4 MHz
  _delay_ms(1);   //some delay
  
  FAT32_active = 1;
  error = getBootSectorData (); //read boot sector and keep necessary data in global variables
  
  if(error) 	
    {
      LCD_command(CLEARSCR);
      LCD_command(FIRST_ROW_START);
      printf_strPGM((PGM_P)(fat32notfound));  //FAT32 incompatible drive
      FAT32_active = 0;
      LCD_command(SECOND_ROW_START);
      printf_strDM((unsigned char*)"Press CONFIRM to recheck");
      while(1) //press confirm to continue
	{
	  if(PINA==0xdf)
	    {
	      while(PINA!=0xff);
	      
	      goto begining; //retesting for SD card initialization
	    }
	}
    }
  
  while(1)
    main_menu();  //main menu control infinite loop
  
  return 0;
}
Beispiel #3
0
int main(void)
{
unsigned char option, error, data, FAT32_active;
unsigned int i;
unsigned char fileName[13];

_delay_ms(100);  //delay for VCC stabilization

init_devices();

PORTD |= 0x04; //switching ON the LED (for testing purpose only)

TX_NEWLINE;
TX_NEWLINE;
transmitString_F (PSTR("***********************************"));
TX_NEWLINE;
transmitString_F (PSTR(" Dharmani's microSD Card Testing.."));
TX_NEWLINE;
transmitString_F (PSTR("***********************************"));
TX_NEWLINE;

SD_init();
SPI_HIGH_SPEED;   //SCK - 4 MHz

_delay_ms(1);

FAT32_active = 1;
error = getBootSectorData (); //read boot sector and keep necessary data in global variables
if(error)  
{
  transmitString_F (PSTR("FAT32 not found!"));  //FAT32 incompatible drive
  FAT32_active = 0;
}

while(1)
{
TX_NEWLINE;
transmitString_F(PSTR("Press any key..."));
TX_NEWLINE;
option = receiveByte();
TX_NEWLINE;
transmitString_F(PSTR("> 0 : Erase Blocks"));
TX_NEWLINE;
transmitString_F(PSTR("> 1 : Write single Block"));
TX_NEWLINE;
transmitString_F(PSTR("> 2 : Read single Block"));

#ifndef FAT_TESTING_ONLY
TX_NEWLINE;
transmitString_F(PSTR("> 3 : Write multiple Blocks"));
TX_NEWLINE;
transmitString_F(PSTR("> 4 : Read multiple Blocks"));
#endif


TX_NEWLINE;
transmitString_F(PSTR("> 5 : Get file list"));
TX_NEWLINE;
transmitString_F(PSTR("> 6 : Read File"));
TX_NEWLINE;
transmitString_F(PSTR("> 7 : Create File"));
TX_NEWLINE;
transmitString_F(PSTR("> 8 : Delete File"));
TX_NEWLINE;
transmitString_F(PSTR("> 9 : Read SD Memory Capacity (Total/Free)"));

TX_NEWLINE;
TX_NEWLINE;
transmitString_F(PSTR("> Select Option (0-9): "));


/*WARNING: If option 0, 1 or 3 is selected, the card may not be detected by PC/Laptop again,
as it disturbs the FAT format, and you may have to format it again with FAT32.
This options are given for learning the raw data transfer to & from the SD Card*/

option = receiveByte();
transmitByte(option);

if(option >= 0x35 && option <= 0x39)  //options 5 to 9 disabled if FAT32 not found
{
  if(!FAT32_active)
  {
    TX_NEWLINE;
    TX_NEWLINE;
      transmitString_F(PSTR("FAT32 options disabled!"));
      continue;
  }
}


if((option >= 0x30) && (option <=0x34)) //get starting block address for options 0 to 4
{
TX_NEWLINE;
TX_NEWLINE;
transmitString_F(PSTR("Enter the Block number (0000-9999):"));
data = receiveByte(); transmitByte(data);
startBlock = (data & 0x0f) * 1000;
data = receiveByte(); transmitByte(data);
startBlock += (data & 0x0f) * 100;
data = receiveByte(); transmitByte(data);
startBlock += (data & 0x0f) * 10;
data = receiveByte(); transmitByte(data);
startBlock += (data & 0x0f);
TX_NEWLINE;
}

totalBlocks = 1;

#ifndef FAT_TESTING_ONLY

if((option == 0x30) || (option == 0x33) || (option == 0x34)) //get total number of blocks for options 0, 3 or 4
{
TX_NEWLINE;
TX_NEWLINE;
transmitString_F(PSTR("How many blocks? (000-999):"));
data = receiveByte(); transmitByte(data);
totalBlocks = (data & 0x0f) * 100;
data = receiveByte(); transmitByte(data);
totalBlocks += (data & 0x0f) * 10;
data = receiveByte(); transmitByte(data);
totalBlocks += (data & 0x0f);
TX_NEWLINE;
}
#endif

switch (option)
{
case '0': //error = SD_erase (block, totalBlocks);
          error = SD_erase (startBlock, totalBlocks);
          TX_NEWLINE;
          if(error)
              transmitString_F(PSTR("Erase failed.."));
          else
              transmitString_F(PSTR("Erased!"));
          break;

case '1': TX_NEWLINE;
          transmitString_F(PSTR(" Enter text (End with ~):"));
          i=0;
            do
            {
                data = receiveByte();
                transmitByte(data);
                buffer[i++] = data;
                if(data == '\r')    //append 'newline' character whenevr 'carriage return' is received
                {
                    transmitByte('\n');
                    buffer[i++] = '\n';
                }
                if(i == 512) break;
            }while (data != '~');

            error = SD_writeSingleBlock (startBlock);
            TX_NEWLINE;
            TX_NEWLINE;
            if(error)
                transmitString_F(PSTR("Write failed.."));
            else
                transmitString_F(PSTR("Write successful!"));
            break;

case '2': error = SD_readSingleBlock (startBlock);
          TX_NEWLINE;
          if(error)
            transmitString_F(PSTR("Read failed.."));
          else
          {
            for(i=0;i<512;i++)
            {
                if(buffer[i] == '~') break;
                transmitByte(buffer[i]);
            }
            TX_NEWLINE;
            TX_NEWLINE;
            transmitString_F(PSTR("Read successful!"));
          }

          break;
//next two options will work only if following macro is cleared from SD_routines.h
#ifndef FAT_TESTING_ONLY

case '3':
          error = SD_writeMultipleBlock (startBlock, totalBlocks);
          TX_NEWLINE;
          if(error)
            transmitString_F(PSTR("Write failed.."));
          else
            transmitString_F(PSTR("Write successful!"));
          break;

case '4': error = SD_readMultipleBlock (startBlock, totalBlocks);
          TX_NEWLINE;
          if(error)
            transmitString_F(PSTR("Read failed.."));
          else
            transmitString_F(PSTR("Read successful!"));
          break;
#endif

case '5': TX_NEWLINE;
              findFiles(GET_LIST,0);
          break;

case '6':
case '7':
case '8': TX_NEWLINE;
              TX_NEWLINE;
          transmitString_F(PSTR("Enter file name: "));
          for(i=0; i<13; i++)
                  fileName[i] = 0x00;   //clearing any previously stored file name
          i=0;
          while(1)
          {
            data = receiveByte();
            if(data == '\r') break;  //'ENTER' key pressed
            if(data == 0x08)  //'Back Space' key pressed
            {
              if(i != 0)
              {
                transmitByte(data);
                transmitByte(' ');
                transmitByte(data);
                i--;
              }
              continue;    
            }
            if(data <0x20 || data > 0x7e) continue;  //check for valid English text character
            transmitByte(data);
            fileName[i++] = data;
            if(i==13){transmitString_F(PSTR(" file name too long..")); break;}
          }
          if(i>12) break;
      
          TX_NEWLINE;
          if(option == '6')
            readFile( READ, fileName);
          if(option == '7')
            createFile(fileName);
          if(option == '8')
            deleteFile(fileName);
          break;

case '9': memoryStatistics();
          break;

default: TX_NEWLINE;
         TX_NEWLINE;
         transmitString_F(PSTR(" Invalid option!"));
         TX_NEWLINE;
}

TX_NEWLINE;
}
return 0;
}
Beispiel #4
0
int main(void) {
	uint16_t BP_1a_avg_mV, BP_1a_min_mV, BP_1a_max_mV;
	uint16_t BP_1b_avg_mV, BP_1b_min_mV, BP_1b_max_mV;
	uint16_t BP_2_avg_mV, BP_2_min_mV, BP_2_max_mV;
	int32_t BP_3a_avg_uV, BP_3a_min_uV, BP_3a_max_uV;
	int32_t BP_3b_avg_uV, BP_3b_min_uV, BP_3b_max_uV;
	int32_t BP_3c_avg_uV, BP_3c_min_uV, BP_3c_max_uV;
	int32_t BP_3d_avg_uV, BP_3d_min_uV, BP_3d_max_uV;
	int32_t BP_3e_avg_uV, BP_3e_min_uV, BP_3e_max_uV;
	int32_t BP_4a_avg_uV, BP_4a_min_uV, BP_4a_max_uV;
	int32_t BP_4b_avg_uV, BP_4b_min_uV, BP_4b_max_uV;
	int32_t BP_4c_avg_uV, BP_4c_min_uV, BP_4c_max_uV;
	int32_t BP_4d_avg_uV, BP_4d_min_uV, BP_4d_max_uV;
	int32_t BP_4e_avg_uV, BP_4e_min_uV, BP_4e_max_uV;
	int32_t BP_5a_avg_uV, BP_5a_min_uV, BP_5a_max_uV;
	int32_t BP_5b_avg_uV, BP_5b_min_uV, BP_5b_max_uV;
	int32_t BP_6a_avg_uV, BP_6a_min_uV, BP_6a_max_uV;
	int32_t BP_6b_avg_uV, BP_6b_min_uV, BP_6b_max_uV;
	int32_t BP_7a_avg_uV, BP_7a_min_uV, BP_7a_max_uV;
	int32_t BP_7b_avg_uV, BP_7b_min_uV, BP_7b_max_uV;
	int32_t BP_8a_avg_uV, BP_8a_min_uV, BP_8a_max_uV;
	int32_t BP_8b_avg_uV, BP_8b_min_uV, BP_8b_max_uV;
	int32_t BP_9a_avg_uV, BP_9a_min_uV, BP_9a_max_uV;
	int32_t BP_9b_avg_uV, BP_9b_min_uV, BP_9b_max_uV;
	int32_t BP_10a_avg_uV, BP_10a_min_uV, BP_10a_max_uV;
	int32_t BP_10b_avg_uV, BP_10b_min_uV, BP_10b_max_uV;
	int32_t BP_11a_avg_uV, BP_11a_min_uV, BP_11a_max_uV, BP_11a_delta_uV, BP_11a_diff1_uV, BP_11a_diff2_uV;
	int32_t BP_11b_avg_uV, BP_11b_min_uV, BP_11b_max_uV, BP_11b_delta_uV, BP_11b_diff1_uV, BP_11b_diff2_uV;
	int32_t BP_12a_avg_uV, BP_12a_min_uV, BP_12a_max_uV, BP_12a_delta_uV, BP_12a_diff1_uV, BP_12a_diff2_uV;
	int32_t BP_12b_avg_uV, BP_12b_min_uV, BP_12b_max_uV, BP_12b_delta_uV, BP_12b_diff1_uV, BP_12b_diff2_uV;
	int32_t BP_13a_avg_uV, BP_13a_min_uV, BP_13a_max_uV, BP_13a_delta_uV, BP_13a_diff1_uV, BP_13a_diff2_uV;
	int32_t BP_13b_avg_uV, BP_13b_min_uV, BP_13b_max_uV, BP_13b_delta_uV, BP_13b_diff1_uV, BP_13b_diff2_uV;
	//uint8_t DATA = {0x05,0x10,0x01,0x05};
	//uint8_t RDATA[512];
	uint8_t filterSettings;
	// set system clock
	set_32MHz();  // for RC clock
	//setXOSC_32MHz();  // for crystal when installed
	// breakpoint 1a - collect room temperature
	CO_collectTemp(&BP_1a_avg_mV, &BP_1a_min_mV, &BP_1a_max_mV);
	// avg 830mV +/- 25% with min/max +/- 1% of avg 
	SD_init();	//initialize SD Card
	//SD_write_and_read_knowns();
	error = getBootSectorData();
	SD_write_and_read_knowns_FAT();
	SD_disable();
	
	//TestRadio();
	chibi_test_radio();
	// breakpoint 1b - collect body temperature
	CO_collectTemp(&BP_1b_avg_mV, &BP_1b_min_mV, &BP_1b_max_mV);
	// avg should increase from breakpoint 1a
	// min/max +/- 1% of avg

	// breakpoint 2 - collect battery voltage
	CO_collectBatt(&BP_2_avg_mV, &BP_2_min_mV, &BP_2_max_mV);
	// avg 400mV +/- 25% with min/max +/- 1% of avg 

	//**********************************************************************
	//************** SETUP EXTERNAL CIRCUIT BEFORE PROCEEDING **************
	//************************ PAST NEXT BREAKPOINT ************************
	//**********************************************************************
	nop();

	//turn on power supply to create signal voltage for test measurements
	//Ext1Power(TRUE);
	
	//set filter for breakpoint 3	
	filterSettings = (uint8_t) (FILTER_CH_1AND5_bm | FILTER_HP_0_bm | FILTER_LP_600_gc);

	// breakpoint 3a - collect sample from Channel 1 (ELEC1/ELEC2) with gain of 1
	CO_collectADC(ADC_CH_1_gc, filterSettings, &BP_3a_avg_uV, &BP_3a_min_uV, &BP_3a_max_uV,
			GAIN_2_gc, SPS_4K_gc);
	// avg 600mV +/- 10% with min/max +/- 1% of avg 
	
	// breakpoint 3b - collect sample from Channel 1 (ELEC1/ELEC2) with gain of 2
	CO_collectADC(ADC_CH_1_gc, filterSettings, &BP_3b_avg_uV, &BP_3b_min_uV, &BP_3b_max_uV,
			GAIN_1_gc, SPS_4K_gc);
	// avg 300mV +/- 10% with min/max +/- 1% of avg 

	Ext1Power(FALSE);

	//**********************************************************************
	//************** SETUP EXTERNAL CIRCUIT BEFORE PROCEEDING **************
	//************************ PAST NEXT BREAKPOINT ************************
	//**********************************************************************
	nop();

	Ext1Power(TRUE);

	// breakpoint 3c - collect sample from Channel 1 (ELEC1/ELEC2) gain of 1
	CO_collectADC(ADC_CH_1_gc, filterSettings, &BP_3c_avg_uV, &BP_3c_min_uV, &BP_3c_max_uV,
			GAIN_1_gc, SPS_4K_gc);
	// avg 0mV +/- 10% with min/max +/- 1% of avg 

	Ext1Power(FALSE);

	//**********************************************************************
	//************** SETUP EXTERNAL CIRCUIT BEFORE PROCEEDING **************
	//************************ PAST NEXT BREAKPOINT ************************
	//**********************************************************************
	nop();

	Ext1Power(TRUE);

	// breakpoint 3d - collect sample from Channel 1 (ELEC1/ELEC2) polarity reversed with gain of 1
	CO_collectADC(ADC_CH_1_gc, filterSettings, &BP_3d_avg_uV, &BP_3d_min_uV, &BP_3d_max_uV,
			GAIN_1_gc, SPS_4K_gc);
	// avg -300mV +/- 10% with min/max +/- 1% of avg 

	// breakpoint 3e - collect sample from Channel 1 (ELEC1/ELEC2) polarity reversed with gain of 2
	CO_collectADC(ADC_CH_1_gc, filterSettings, &BP_3e_avg_uV, &BP_3e_min_uV, &BP_3e_max_uV,
			GAIN_2_gc, SPS_4K_gc);
	// avg -600mV +/- 10% with min/max +/- 1% of avg 

	Ext1Power(FALSE);

	//**********************************************************************
	//************** SETUP EXTERNAL CIRCUIT BEFORE PROCEEDING **************
	//************************ PAST NEXT BREAKPOINT ************************
	//**********************************************************************
	nop();

	Ext1Power(TRUE);

	// set filter for breakpoint 4
	filterSettings = (uint8_t) (FILTER_CH_2AND6_bm | FILTER_HP_0_bm | FILTER_LP_600_gc);

	// breakpoint 4a - collect sample from Channel 2 (ELEC3/ELEC4) with gain of 2
	CO_collectADC(ADC_CH_2_gc, filterSettings, &BP_4a_avg_uV, &BP_4a_min_uV, &BP_4a_max_uV,
			GAIN_2_gc, SPS_4K_gc);
	// avg 600mV +/- 10% with min/max +/- 1% of avg 

	// breakpoint 4b - collect sample from Channel 2 (ELEC3/ELEC4) with gain of 1
	CO_collectADC(ADC_CH_2_gc, filterSettings, &BP_4b_avg_uV, &BP_4b_min_uV, &BP_4b_max_uV,
			GAIN_1_gc, SPS_4K_gc);
	// avg 300mV +/- 10% with min/max +/- 1% of avg 

	Ext1Power(FALSE);

	//**********************************************************************
	//************** SETUP EXTERNAL CIRCUIT BEFORE PROCEEDING **************
	//************************ PAST NEXT BREAKPOINT ************************
	//**********************************************************************
	nop();

	Ext1Power(TRUE);

	// breakpoint 4c - collect sample from Channel 2 (ELEC3/ELEC4) with gain of 1
	CO_collectADC(ADC_CH_2_gc, filterSettings, &BP_4c_avg_uV, &BP_4c_min_uV, &BP_4c_max_uV,
			GAIN_1_gc, SPS_4K_gc);
	// avg 0mV +/- 10% with min/max +/- 1% of avg

	Ext1Power(FALSE);

	//**********************************************************************
	//************** SETUP EXTERNAL CIRCUIT BEFORE PROCEEDING **************
	//************************ PAST NEXT BREAKPOINT ************************
	//**********************************************************************
	nop();

	Ext1Power(TRUE);

	// breakpoint 4d - collect sample from Channel 2 (ELEC3/ELEC4) polarity reversed with gain of 1
	CO_collectADC(ADC_CH_2_gc, filterSettings, &BP_4d_avg_uV, &BP_4d_min_uV, &BP_4d_max_uV,
			GAIN_1_gc, SPS_4K_gc);
	// avg -300mV +/- 10% with min/max +/- 1% of avg


	// breakpoint 4e - collect sample from Channel 2 (ELEC3/ELEC4) polarity reversed with gain of 2
	CO_collectADC(ADC_CH_2_gc, filterSettings, &BP_4e_avg_uV, &BP_4e_min_uV, &BP_4e_max_uV,
			GAIN_2_gc, SPS_4K_gc);
	// avg -600mV +/- 10% with min/max +/- 1% of avg

	Ext1Power(FALSE);

	//**********************************************************************
	//************** SETUP EXTERNAL CIRCUIT BEFORE PROCEEDING **************
	//************************ PAST NEXT BREAKPOINT ************************
	//**********************************************************************
	nop();

	Ext1Power(TRUE);
	HVPower(TRUE);

	// set filter for breakpoint 5
	filterSettings = (uint8_t) (FILTER_CH_4AND8_bm | FILTER_HP_0_bm | FILTER_LP_600_gc);
	
	// breakpoint 5a - collect sample from Channel 4 with gain of 1
	CO_collectADC(ADC_CH_4_gc, filterSettings, &BP_5a_avg_uV, &BP_5a_min_uV, &BP_5a_max_uV,
			GAIN_1_gc, SPS_4K_gc);
	// avg 293mV +/- 10% with min/max +/- 1% of avg
	
	HVPower(FALSE);
	Ext1Power(FALSE);
	
	
	//**********************************************************************
	//************** SETUP EXTERNAL CIRCUIT BEFORE PROCEEDING **************
	//************************ PAST NEXT BREAKPOINT ************************
	//**********************************************************************
	nop();

	Ext1Power(TRUE);
	HVPower(TRUE);
	
	// breakpoint 5b - collect sample from Channel 4 with gain of 1
	CO_collectADC(ADC_CH_4_gc, filterSettings, &BP_5b_avg_uV, &BP_5b_min_uV, &BP_5b_max_uV,
			GAIN_1_gc, SPS_4K_gc);
	// avg 571mV +/- 10% with min/max +/- 1% of avg

	HVPower(FALSE);
	Ext1Power(FALSE);

	//**********************************************************************
	//************** SETUP EXTERNAL CIRCUIT BEFORE PROCEEDING **************
	//************************ PAST NEXT BREAKPOINT ************************
	//**********************************************************************
	nop();

	Ext1Power(TRUE);
	HVPower(TRUE);
	
	// set filter for breakpoint 6
	filterSettings = (uint8_t) (FILTER_CH_1AND5_bm | FILTER_HP_0_bm | FILTER_LP_600_gc);

	// breakpoint 6a - collect sample from Channel 5 with gain of 1
	CO_collectADC(ADC_CH_5_gc, filterSettings, &BP_6a_avg_uV, &BP_6a_min_uV, &BP_6a_max_uV,
			GAIN_1_gc, SPS_4K_gc);
	// avg ??mV +/- 10% with min/max +/- 1% of avg

	HVPower(FALSE);
	Ext1Power(FALSE);

	//**********************************************************************
	//************** SETUP EXTERNAL CIRCUIT BEFORE PROCEEDING **************
	//************************ PAST NEXT BREAKPOINT ************************
	//**********************************************************************
	nop();

	Ext1Power(TRUE);
	HVPower(TRUE);

	// breakpoint 6b - collect sample from Channel 4 with gain of 1
	CO_collectADC(ADC_CH_5_gc, filterSettings, &BP_6b_avg_uV, &BP_6b_min_uV, &BP_6b_max_uV,
			GAIN_1_gc, SPS_4K_gc);
	// avg ??mV +/- 10% with min/max +/- 1% of avg

	HVPower(FALSE);
	Ext1Power(FALSE);


	//**********************************************************************
	//************** SETUP EXTERNAL CIRCUIT BEFORE PROCEEDING **************
	//************************ PAST NEXT BREAKPOINT ************************
	//**********************************************************************
	nop();

	Ext1Power(TRUE);

	// breakpoint 7a - write known values with checksums to FRAM
	// read known values back from FRAM and recalculate checksums
	FRAMWriteKnownsCheck();
	// checksumADC[0] = checkSumFRAM[0] = 0x37 = 55
	// checksumADC[0] = checkSumFRAM[0] = 0xC9 = 201
	// checksumADC[0] = checkSumFRAM[0] = 0x35 = 53
	// sumFRAM[0] = sumFRAM[1] = sumFRAM[2] = 18CC5ED67 = 6656748903


	// breakpoint 7b - collect sample from all three seismic channels with
	// checksums on FRAM writes and read back recalculating checksums
	FRAMTest3Channel();
	// checksumADC and checkSumFRAM match

	// breakpoint 7c - collect sample from all three seismic channels with
	// checksums on FRAM writes and read back recalculating checksums
	FRAMTest1Channel();
	// checksumADC and checkSumFRAM match 

	Ext1Power(TRUE);

	nop();

	Ext1Power(TRUE);

	// set filter for breakpoint 7
	filterSettings = (uint8_t) (FILTER_CH_1AND5_bm | FILTER_HP_0_bm | FILTER_LP_600_gc);

	// breakpoint 7a - collect sample from Channel 5 with gain of 1
	CO_collectADC(ADC_CH_5_gc, filterSettings, &BP_7a_avg_uV, &BP_7a_min_uV, &BP_7a_max_uV,
			GAIN_1_gc, SPS_4K_gc);
	// avg ??mV +/- 10% with min/max +/- 1% of avg

	// breakpoint 7b - collect sample from Channel 5 with gain of 1
	CO_collectADC(ADC_CH_5_gc, filterSettings, &BP_7b_avg_uV, &BP_7b_min_uV, &BP_7b_max_uV,
			GAIN_1_gc, SPS_4K_gc);
	// avg ??mV +/- 10% with min/max +/- 1% of avg

	Ext1Power(FALSE);

	//**********************************************************************
	//************ TEARDOWN EXTERNAL CIRCUIT BEFORE PROCEEDING *************
	//************************ PAST NEXT BREAKPOINT ************************
	//**********************************************************************
	nop();

	// set filter for breakpoint 8
	filterSettings = (uint8_t) (FILTER_CH_2AND6_bm | FILTER_HP_0_bm | FILTER_LP_600_gc);

	// breakpoint 8a - collect sample from Channel 6 (ACC x-axis) with gain of 1
	// configure board resting on long edge with J1 facing up
	CO_collectADC(ADC_CH_6_gc, filterSettings, &BP_8a_avg_uV, &BP_8a_min_uV, &BP_8a_max_uV,
			GAIN_1_gc, SPS_4K_gc);
	// avg ??mV +/- 10% with min/max +/- 1% of avg

	// breakpoint 8b - collect sample from Channel 6 (ACC x-axis) with gain of 1
	// configure board resting on long edge with J1 facing down
 	CO_collectADC(ADC_CH_6_gc, filterSettings, &BP_8b_avg_uV, &BP_8b_min_uV, &BP_8b_max_uV,
			GAIN_1_gc, SPS_4K_gc);
	// avg ??mV +/- 10% with min/max +/- 1% of avg

	// set filter for breakpoint 9
	filterSettings = (uint8_t) (FILTER_CH_3AND7_bm | FILTER_HP_0_bm | FILTER_LP_600_gc);

	// breakpoint 9a - collect sample from Channel 7 (ACC y-axis) with gain of 1
	// configure board resting vertically short edge with J1 facing up
	CO_collectADC(ADC_CH_7_gc, filterSettings, &BP_9a_avg_uV, &BP_9a_min_uV, &BP_9a_max_uV,
			GAIN_1_gc, SPS_4K_gc);
	// avg ??mV +/- 10% with min/max +/- 1% of avg

	// breakpoint 9b - collect sample from Channel 7 (ACC y-axis) with gain of 1
	// configure board resting vertically short edge with J1 facing down
	CO_collectADC(ADC_CH_7_gc, filterSettings, &BP_9b_avg_uV, &BP_9b_min_uV, &BP_9b_max_uV,
			GAIN_1_gc, SPS_4K_gc);
	// avg ??mV +/- 10% with min/max +/- 1% of avg
	
	// set filter for breakpoint 10
	filterSettings = (uint8_t) (FILTER_CH_3AND7_bm | FILTER_HP_0_bm | FILTER_LP_600_gc);

	// breakpoint 10a - collect sample from Channel 8 (ACC z-axis) with gain of 1
	// configure board resting lies flat with J1 facing up
	CO_collectADC(ADC_CH_8_gc, filterSettings, &BP_10a_avg_uV, &BP_10a_min_uV, &BP_10a_max_uV,
			GAIN_1_gc, SPS_4K_gc);
	// avg ??mV +/- 10% with min/max +/- 1% of avg

	// breakpoint 10b - collect sample from Channel 8 (ACC z-axis) with gain of 1
	// configure board resting lies flat with J1 facing down
	CO_collectADC(ADC_CH_8_gc, filterSettings, &BP_10b_avg_uV, &BP_10b_min_uV, &BP_10b_max_uV,
			GAIN_1_gc, SPS_4K_gc);
	// avg ??mV +/- 10% with min/max +/- 1% of avg
	
	//**********************************************************************
	//************ SETUP SINE WAVE GENERATOR BEFORE PROCEEDING *************
	//************************ PAST NEXT BREAKPOINT ************************
	//**********************************************************************
	nop();

	// set filter for breakpoint 11
	filterSettings = (uint8_t) (FILTER_CH_2AND6_bm | FILTER_HP_0_bm | FILTER_LP_600_gc);

	// breakpoint 11a - collect sample from Channel 6 (ACC x-axis) with gain of 16
	CO_collectADC(ADC_CH_6_gc, filterSettings, &BP_11a_avg_uV, &BP_11a_min_uV, &BP_11a_max_uV,
			GAIN_16_gc, SPS_4K_gc);
	BP_11a_delta_uV = BP_11a_max_uV - BP_11a_min_uV;
	BP_11a_diff1_uV = BP_11a_max_uV - BP_11a_avg_uV;
	BP_11a_diff2_uV = BP_11a_avg_uV - BP_11a_min_uV;
	nop();
	// delta value of ??mV and diff1/diff2 within ??% of each other

	// breakpoint 11b - collect sample from Channel 6 (ACC x-axis) with gain of 16
	CO_collectADC(ADC_CH_6_gc, filterSettings, &BP_11b_avg_uV, &BP_11b_min_uV, &BP_11b_max_uV,
			GAIN_16_gc, SPS_4K_gc);
	BP_11b_delta_uV = BP_11b_max_uV - BP_11b_min_uV;
	BP_11b_diff1_uV = BP_11b_max_uV - BP_11b_avg_uV;
	BP_11b_diff2_uV = BP_11b_avg_uV - BP_11b_min_uV;
	nop();
	// delta value of ??mV and diff1/diff2 within ??% of each other

	// set filter for breakpoint 12
	filterSettings = (uint8_t) (FILTER_CH_3AND7_bm | FILTER_HP_0_bm | FILTER_LP_600_gc);

	// breakpoint 12a - collect sample from Channel 7 (ACC y-axis) with gain of 16
	CO_collectADC(ADC_CH_7_gc, filterSettings, &BP_12a_avg_uV, &BP_12a_min_uV, &BP_12a_max_uV,
			GAIN_16_gc, SPS_4K_gc);
	BP_12a_delta_uV = BP_12a_max_uV - BP_12a_min_uV;
	BP_12a_diff1_uV = BP_12a_max_uV - BP_12a_avg_uV;
	BP_12a_diff2_uV = BP_12a_avg_uV - BP_12a_min_uV;
	nop();
	// delta value of ??mV and diff1/diff2 within ??% of each other

	// breakpoint 12b - collect sample from Channel 7 (ACC y-axis) with gain of 16
	CO_collectADC(ADC_CH_7_gc, filterSettings, &BP_12b_avg_uV, &BP_12b_min_uV, &BP_12b_max_uV,
			GAIN_16_gc, SPS_4K_gc);
	BP_12b_delta_uV = BP_12b_max_uV - BP_12b_min_uV;
	BP_12b_diff1_uV = BP_12b_max_uV - BP_12b_avg_uV;
	BP_12b_diff2_uV = BP_12b_avg_uV - BP_12b_min_uV;
	nop();
	// delta value of ??mV and diff1/diff2 within ??% of each other
	
	// set filter for breakpoint 13
	filterSettings = (uint8_t) (FILTER_CH_3AND7_bm | FILTER_HP_0_bm | FILTER_LP_600_gc);

	// breakpoint 13a - collect sample from Channel 8 (ACC z-axis) with gain of 16
	CO_collectADC(ADC_CH_8_gc, filterSettings, &BP_13a_avg_uV, &BP_13a_min_uV, &BP_13a_max_uV,
			GAIN_16_gc, SPS_4K_gc);
	BP_13a_delta_uV = BP_13a_max_uV - BP_13a_min_uV;
	BP_13a_diff1_uV = BP_13a_max_uV - BP_13a_avg_uV;
	BP_13a_diff2_uV = BP_13a_avg_uV - BP_13a_min_uV;
	nop();
	// delta value of ??mV and diff1/diff2 within ??% of each other

	// breakpoint 13b - collect sample from Channel 8 (ACC z-axis) with gain of 16
	// configure board resting lies flat with J1 facing down
	CO_collectADC(ADC_CH_8_gc, filterSettings, &BP_13b_avg_uV, &BP_13b_min_uV, &BP_13b_max_uV,
			GAIN_16_gc, SPS_4K_gc);
	BP_13b_delta_uV = BP_13b_max_uV - BP_13b_min_uV;
	BP_13b_diff1_uV = BP_13b_max_uV - BP_13b_avg_uV;
	BP_13b_diff2_uV = BP_13b_avg_uV - BP_13b_min_uV;
	nop();
	// delta value of ??mV and diff1/diff2 within ??% of each other

	while(1);
}