/****************************************************************************************************/
/**
\file       PDB.c
\author     Freescale Semiconductor
\author     Technical Information Center (TIC)
\version    1.0
\date		June, 2010	        
*/
/****************************************************************************************************/
/* Services performed by FREESCALE in this matter are performed AS IS and without any warranty.  	  */
/* CUSTOMER retains the final decision relative to the total design and functionality of the end 	  */
/* product.                                                                                      	  */
/* FREESCALE neither guarantees nor will be held liable by CUSTOMER for the success of this project.*/
/*                                                                                                  */
/* FREESCALE disclaims all warranties, express, implied or statutory including, but not limited to, */
/* implied warranty of merchantability or fitness for a particular purpose on any hardware,         */
/* software ore advise supplied to the project by FREESCALE, and or any product resulting from      */
/* FREESCALE services.                                                                              */
/* In no event shall FREESCALE be liable for incidental or consequential damages arising out of     */
/* this agreement. CUSTOMER agrees to hold FREESCALE harmless against any and all claims demands or */
/* actions by anyone on account of any damage,or injury, whether commercial, contractual, or        */
/* tortuous, rising directly or indirectly as a result of the advise or assistance supplied CUSTOMER*/ 
/* in connectionwith product, services or goods supplied under this Agreement.                      */
/*                                                                                                  */
/****************************************************************************************************/


/*****************************************************************************************************
* Include files
*****************************************************************************************************/
#include "PDB.h"
/*****************************************************************************************************
* Declaration of module wide FUNCTIONs - NOT for use in other modules
*****************************************************************************************************/

/*****************************************************************************************************
* Definition of module wide MACROs / #DEFINE-CONSTANTs - NOT for use in other modules
*****************************************************************************************************/

/*****************************************************************************************************
* Declaration of module wide TYPEs - NOT for use in other modules
*****************************************************************************************************/

/*****************************************************************************************************
* Definition of module wide VARIABLEs - NOT for use in other modules
*****************************************************************************************************/
struct tPDB sPDB;
/*****************************************************************************************************
* Definition of module wide (CONST-) CONSTANTs - NOT for use in other modules
*****************************************************************************************************/

/*****************************************************************************************************
* Code of project wide FUNCTIONS
*****************************************************************************************************/

/****************************************************************************************************/
/**
* \brief 	
* \param      
* \return   
* \todo     
*/

/****************************************************************************************************/
void vfnPDBInit (void)
{
   PDBC1 = PDB_TRG_SOFTWARE | PDBC1_CONT_MASK | PDB_PSL_4;
   
   PDBSC_DACTOE = 0b1;
   
   PDBMOD = 6000;	//Modulus is 0.33us*400 ticks = 132us
   DACINT = 3000; 	//DAC trigger interval 0.33us*50 ticks = 16.5us
   



}

void vfnPDBConfig (UINT8 u8Mode)
{
	   PDBSC_LDOK = 0b1;	//load buffered registers
	   while(PDBSC_LDOK);	//wait till LDOK is cleared
	   
	   PDBSC_PDBEN = 1;		//Counter enable
	   
	   PDBC2_SWTRIG = 1;	
}
