начало
This commit is contained in:
42
v120/DSP2833x_common/source/DSP2833x_ADC_cal.asm
Normal file
42
v120/DSP2833x_common/source/DSP2833x_ADC_cal.asm
Normal file
@@ -0,0 +1,42 @@
|
||||
;; TI File $Revision: /main/1 $
|
||||
;; Checkin $Date: July 30, 2007 10:29:23 $
|
||||
;;###########################################################################
|
||||
;;
|
||||
;; FILE: ADC_cal.asm
|
||||
;;
|
||||
;; TITLE: 2833x Boot Rom ADC Cal routine.
|
||||
;;
|
||||
;; Functions:
|
||||
;;
|
||||
;; _ADC_cal - Copies device specific calibration data into ADCREFSEL and ADCOFFTRIM registers
|
||||
;; Notes:
|
||||
;;
|
||||
;;###########################################################################
|
||||
;; $TI Release: DSP2833x/DSP2823x Header Files V1.20 $
|
||||
;; $Release Date: August 1, 2008 $
|
||||
;;###########################################################################
|
||||
|
||||
.def _ADC_cal
|
||||
.asg "0x711C", ADCREFSEL_LOC
|
||||
|
||||
;-----------------------------------------------
|
||||
; _ADC_cal
|
||||
;-----------------------------------------------
|
||||
;-----------------------------------------------
|
||||
; This is the ADC cal routine.This routine is programmed into
|
||||
; reserved memory by the factory. 0xAAAA and 0xBBBB are place-
|
||||
; holders for calibration data.
|
||||
;The actual values programmed by TI are device specific.
|
||||
;
|
||||
; This function assumes that the clocks have been
|
||||
; enabled to the ADC module.
|
||||
;-----------------------------------------------
|
||||
|
||||
.sect ".adc_cal"
|
||||
|
||||
_ADC_cal
|
||||
MOVW DP, #ADCREFSEL_LOC >> 6
|
||||
MOV @28, #0xAAAA ; actual value may not be 0xAAAA
|
||||
MOV @29, #0xBBBB ; actual value may not be 0xBBBB
|
||||
LRETR
|
||||
;eof ----------
|
||||
65
v120/DSP2833x_common/source/DSP2833x_Adc.c
Normal file
65
v120/DSP2833x_common/source/DSP2833x_Adc.c
Normal file
@@ -0,0 +1,65 @@
|
||||
// TI File $Revision: /main/5 $
|
||||
// Checkin $Date: October 23, 2007 13:34:09 $
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: DSP2833x_Adc.c
|
||||
//
|
||||
// TITLE: DSP2833x ADC Initialization & Support Functions.
|
||||
//
|
||||
//###########################################################################
|
||||
// $TI Release: DSP2833x/DSP2823x Header Files V1.20 $
|
||||
// $Release Date: August 1, 2008 $
|
||||
//###########################################################################
|
||||
|
||||
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
|
||||
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
|
||||
|
||||
#define ADC_usDELAY 5000L
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// InitAdc:
|
||||
//---------------------------------------------------------------------------
|
||||
// This function initializes ADC to a known state.
|
||||
//
|
||||
void InitAdc(void)
|
||||
{
|
||||
extern void DSP28x_usDelay(Uint32 Count);
|
||||
|
||||
|
||||
// *IMPORTANT*
|
||||
// The ADC_cal function, which copies the ADC calibration values from TI reserved
|
||||
// OTP into the ADCREFSEL and ADCOFFTRIM registers, occurs automatically in the
|
||||
// Boot ROM. If the boot ROM code is bypassed during the debug process, the
|
||||
// following function MUST be called for the ADC to function according
|
||||
// to specification. The clocks to the ADC MUST be enabled before calling this
|
||||
// function.
|
||||
// See the device data manual and/or the ADC Reference
|
||||
// Manual for more information.
|
||||
|
||||
EALLOW;
|
||||
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;
|
||||
ADC_cal();
|
||||
EDIS;
|
||||
|
||||
|
||||
|
||||
|
||||
// To powerup the ADC the ADCENCLK bit should be set first to enable
|
||||
// clocks, followed by powering up the bandgap, reference circuitry, and ADC core.
|
||||
// Before the first conversion is performed a 5ms delay must be observed
|
||||
// after power up to give all analog circuits time to power up and settle
|
||||
|
||||
// Please note that for the delay function below to operate correctly the
|
||||
// CPU_RATE define statement in the DSP2833x_Examples.h file must
|
||||
// contain the correct CPU clock period in nanoseconds.
|
||||
|
||||
AdcRegs.ADCREFSEL.bit.REF_SEL = 0x01;
|
||||
AdcRegs.ADCTRL3.all = 0x00E0; // Power up bandgap/reference/ADC circuits
|
||||
DELAY_US(ADC_usDELAY); // Delay before converting ADC channels
|
||||
//pause_us(50L);
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// End of file.
|
||||
//===========================================================================
|
||||
115
v120/DSP2833x_common/source/DSP2833x_CpuTimers.c
Normal file
115
v120/DSP2833x_common/source/DSP2833x_CpuTimers.c
Normal file
@@ -0,0 +1,115 @@
|
||||
// TI File $Revision: /main/3 $
|
||||
// Checkin $Date: March 16, 2007 08:37:30 $
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: DSP2833x_CpuTimers.c
|
||||
//
|
||||
// TITLE: CPU 32-bit Timers Initialization & Support Functions.
|
||||
//
|
||||
// NOTES: CpuTimer1 and CpuTimer2 are reserved for use with DSP BIOS and
|
||||
// other realtime operating systems.
|
||||
//
|
||||
// Do not use these two timers in your application if you ever plan
|
||||
// on integrating DSP-BIOS or another realtime OS.
|
||||
//
|
||||
//
|
||||
//###########################################################################
|
||||
// $TI Release: DSP2833x/DSP2823x Header Files V1.20 $
|
||||
// $Release Date: August 1, 2008 $
|
||||
//###########################################################################
|
||||
|
||||
#include "DSP2833x_Device.h" // Headerfile Include File
|
||||
#include "DSP2833x_Examples.h" // Examples Include File
|
||||
|
||||
struct CPUTIMER_VARS CpuTimer0;
|
||||
|
||||
// CpuTimer 1 and CpuTimer2 are used by DSP BIOS & other RTOS. Comment out if using DSP BIOS or other RTOS.
|
||||
struct CPUTIMER_VARS CpuTimer1;
|
||||
struct CPUTIMER_VARS CpuTimer2;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// InitCpuTimers:
|
||||
//---------------------------------------------------------------------------
|
||||
// This function initializes all three CPU timers to a known state.
|
||||
//
|
||||
void InitCpuTimers(void)
|
||||
{
|
||||
// CPU Timer 0
|
||||
// Initialize address pointers to respective timer registers:
|
||||
CpuTimer0.RegsAddr = &CpuTimer0Regs;
|
||||
// Initialize timer period to maximum:
|
||||
CpuTimer0Regs.PRD.all = 0xFFFFFFFF;
|
||||
// Initialize pre-scale counter to divide by 1 (SYSCLKOUT):
|
||||
CpuTimer0Regs.TPR.all = 0;
|
||||
CpuTimer0Regs.TPRH.all = 0;
|
||||
// Make sure timer is stopped:
|
||||
CpuTimer0Regs.TCR.bit.TSS = 1;
|
||||
// Reload all counter register with period value:
|
||||
CpuTimer0Regs.TCR.bit.TRB = 1;
|
||||
// Reset interrupt counters:
|
||||
CpuTimer0.InterruptCount = 0;
|
||||
|
||||
|
||||
// CpuTimer 1 and CpuTimer2 are reserved for DSP BIOS & other RTOS
|
||||
// Do not use these two timers if you ever plan on integrating
|
||||
// DSP-BIOS or another realtime OS.
|
||||
//
|
||||
// Initialize address pointers to respective timer registers:
|
||||
CpuTimer1.RegsAddr = &CpuTimer1Regs;
|
||||
CpuTimer2.RegsAddr = &CpuTimer2Regs;
|
||||
// Initialize timer period to maximum:
|
||||
CpuTimer1Regs.PRD.all = 0xFFFFFFFF;
|
||||
CpuTimer2Regs.PRD.all = 0xFFFFFFFF;
|
||||
// Initialize pre-scale counter to divide by 1 (SYSCLKOUT):
|
||||
CpuTimer1Regs.TPR.all = 0;
|
||||
CpuTimer1Regs.TPRH.all = 0;
|
||||
CpuTimer2Regs.TPR.all = 0;
|
||||
CpuTimer2Regs.TPRH.all = 0;
|
||||
// Make sure timers are stopped:
|
||||
CpuTimer1Regs.TCR.bit.TSS = 1;
|
||||
CpuTimer2Regs.TCR.bit.TSS = 1;
|
||||
// Reload all counter register with period value:
|
||||
CpuTimer1Regs.TCR.bit.TRB = 1;
|
||||
CpuTimer2Regs.TCR.bit.TRB = 1;
|
||||
// Reset interrupt counters:
|
||||
CpuTimer1.InterruptCount = 0;
|
||||
CpuTimer2.InterruptCount = 0;
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// ConfigCpuTimer:
|
||||
//---------------------------------------------------------------------------
|
||||
// This function initializes the selected timer to the period specified
|
||||
// by the "Freq" and "Period" parameters. The "Freq" is entered as "MHz"
|
||||
// and the period in "uSeconds". The timer is held in the stopped state
|
||||
// after configuration.
|
||||
//
|
||||
void ConfigCpuTimer(struct CPUTIMER_VARS *Timer, float Freq, float Period)
|
||||
{
|
||||
Uint32 temp;
|
||||
|
||||
// Initialize timer period:
|
||||
Timer->CPUFreqInMHz = Freq;
|
||||
Timer->PeriodInUSec = Period;
|
||||
temp = (long) (Freq * Period);
|
||||
Timer->RegsAddr->PRD.all = temp;
|
||||
|
||||
// Set pre-scale counter to divide by 1 (SYSCLKOUT):
|
||||
Timer->RegsAddr->TPR.all = 0;
|
||||
Timer->RegsAddr->TPRH.all = 0;
|
||||
|
||||
// Initialize timer control register:
|
||||
Timer->RegsAddr->TCR.bit.TSS = 1; // 1 = Stop timer, 0 = Start/Restart Timer
|
||||
Timer->RegsAddr->TCR.bit.TRB = 1; // 1 = reload timer
|
||||
Timer->RegsAddr->TCR.bit.SOFT = 0;
|
||||
Timer->RegsAddr->TCR.bit.FREE = 0; // Timer Free Run Disabled
|
||||
Timer->RegsAddr->TCR.bit.TIE = 1; // 0 = Disable/ 1 = Enable Timer Interrupt
|
||||
|
||||
// Reset interrupt counter:
|
||||
Timer->InterruptCount = 0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// End of file.
|
||||
//===========================================================================
|
||||
Reference in New Issue
Block a user