АЦП переведён в дифференциальный режим (но это ничего не изменило)

This commit is contained in:
seklyuts 2024-08-26 16:43:09 +03:00
parent aefcee53fb
commit 0c392b202f
8 changed files with 71 additions and 21 deletions

View File

@ -142,6 +142,13 @@ void GpioInit(void)
GpioDataRegs.GPDDAT.bit.GPIO98 = 0; //BISS-C_PWR_12V/5V
GpioCtrlRegs.GPDCSEL1.bit.GPIO98 = 2;
GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 0;
GpioCtrlRegs.GPAGMUX1.bit.GPIO14 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO14 = 1;
GpioDataRegs.GPADAT.bit.GPIO14 = 0;
GpioCtrlRegs.GPACSEL2.bit.GPIO14 = 2;
#endif
EDIS;
}

View File

@ -134,9 +134,7 @@ void PWMGpioInit(void)//<2F><><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>
GpioCtrlRegs.GPACSEL1.bit.GPIO6 = 2;//to cpu2
GpioCtrlRegs.GPACSEL1.bit.GPIO7 = 2;
#endif
// GpioCtrlRegs.GPAPUD.bit.GPIO14 = 1; // Disable pull-up on GPIO14 (EPWM8A)
// GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 1; // Configure GPIO14 as EPWM8A
// GpioCtrlRegs.GPACSEL2.bit.GPIO14 = 2;//to cpu2
GpioCtrlRegs.GPAPUD.bit.GPIO4 = 1; // Disable pull-up on GPIO4 (EPWM3A)
GpioCtrlRegs.GPAPUD.bit.GPIO5 = 1; // Disable pull-up on GPIO5 (EPWM3B)

View File

@ -53,6 +53,14 @@
#define CONNECT_ADCA(x) EALLOW; DevCfgRegs.CPUSEL11.bit.ADC_A = x; EDIS
#define CONNECT_RAM_GS0(x) EALLOW; MemCfgRegs.GSxMSEL.bit.MSEL_GS0 = x; EDIS
#define CONNECT_RAM_GS1(x) EALLOW; MemCfgRegs.GSxMSEL.bit.MSEL_GS1 = x; EDIS
#define CONNECT_RAM_GS2(x) EALLOW; MemCfgRegs.GSxMSEL.bit.MSEL_GS2 = x; EDIS
#define CONNECT_RAM_GS3(x) EALLOW; MemCfgRegs.GSxMSEL.bit.MSEL_GS3 = x; EDIS
#define CONNECT_RAM_GS4(x) EALLOW; MemCfgRegs.GSxMSEL.bit.MSEL_GS4 = x; EDIS
#define CONNECT_RAM_GS5(x) EALLOW; MemCfgRegs.GSxMSEL.bit.MSEL_GS5 = x; EDIS
void InitPerif(void)
{
@ -130,6 +138,12 @@ void InitPerif(void)
CONNECT_CLB1(TO_CPU2);
CONNECT_CLB2(TO_CPU2);
CONNECT_ADCA(TO_CPU2);
CONNECT_RAM_GS0(TO_CPU2);
CONNECT_RAM_GS1(TO_CPU2);
CONNECT_RAM_GS2(TO_CPU2);
CONNECT_RAM_GS3(TO_CPU2);
CONNECT_RAM_GS4(TO_CPU2);
CONNECT_RAM_GS5(TO_CPU2);
Cpu1toCpu2IpcRegs.CPU1TOCPU2IPCBOOTMODE = 0x5A00C803; //str 716
Cpu1toCpu2IpcRegs.CPU1TOCPU2IPCSET.bit.IPC0 = 1;

View File

@ -74,7 +74,7 @@ SECTIONS
#if defined(__TI_EABI__)
.init_array : > FLASH1, ALIGN(8)
.bss : >> RAMLS5 | RAMLS6 // instead of RAMLS5
.bss : >> RAMLS5 | RAMLS6 | RAMLS7// instead of RAMLS5
.bss:output : > RAMLS3
.bss:cio : > RAMLS5
.data : > RAMLS5
@ -99,14 +99,20 @@ SECTIONS
MSGRAM_CM_TO_CPU : > CMTOCPURAM, type=NOINIT
/* The following section definition are for SDFM examples */
Filter_RegsFile : > RAMGS10
// Filter_RegsFile : > RAMGS10
Filter1_RegsFile : > RAMLS1
Filter2_RegsFile : > RAMLS2
Filter3_RegsFile : > RAMLS3
Filter4_RegsFile : > RAMLS4
Filter6_RegsFile : > RAMLS6
Filter14_RegsFile : > RAMGS14
Difference_RegsFile : >RAMGS5
ADC_RegsFile0 : > RAMGS0 | RAMGS1 | RAMGS2
ADC_RegsFile1 : > RAMGS3 | RAMGS4 | RAMGS5
// Filter14_RegsFile : > RAMGS14
// Difference_RegsFile : >RAMGS5
#if defined(__TI_EABI__)
.TI.ramfunc : {} LOAD = FLASH3,

View File

@ -12,14 +12,32 @@ Uint16 AdcaResult1;
int16 ADCdiff;
Uint16 adc_start = 0;
//uint16_t AdcaResult0_[4096];
//uint16_t AdcaResult1_[4096];
//#pragma DATA_SECTION(AdcaResult0_,"ADC_RegsFile0");
//#pragma DATA_SECTION(AdcaResult1_,"ADC_RegsFile1");
uint16_t N_ = 0;
__interrupt void adca1_isr(void)
{
AdcaResult0 = AdcaResultRegs.ADCRESULT0;
AdcaResult1 = AdcaResultRegs.ADCRESULT1;
// AdcaResult1 = AdcaResultRegs.ADCRESULT1;
// if(N_ < 4096)
// {
// AdcaResult0_[N_] = AdcaResult0;
// AdcaResult1_[N_] = AdcaResult1;
// N_++;
// }
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
ADCdiff = AdcaResult0 - AdcaResult1;
// ADCdiff = AdcaResult0 - AdcaResult1;
//
// Acknowledge
//
@ -41,15 +59,15 @@ void ADCConfigure(void)
// Write configurations
//
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
//AdcSetMode(ADC_ADCA, ADC_RESOLUTION_16BIT, ADC_SIGNALMODE_SINGLE);
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_16BIT, ADC_SIGNALMODE_DIFFERENTIAL);
//
// Set pulse positions to late
//
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
AdcaRegs.ADCCTL2.bit.SIGNALMODE = 0;
//
// Power up the ADC
//
@ -62,13 +80,13 @@ void ADCConfigure(void)
//ADCB
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 will convert pin B0
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 will convert pin A0
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 14; //sample window is acqps +
//1 SYSCLK cycles
AdcaRegs.ADCSOC1CTL.bit.CHSEL = 1; //SOC1 will convert pin B1
AdcaRegs.ADCSOC1CTL.bit.ACQPS = 14; //sample window is acqps +
// AdcaRegs.ADCSOC1CTL.bit.CHSEL = 1; //SOC1 will convert pin A1
// AdcaRegs.ADCSOC1CTL.bit.ACQPS = 14; //sample window is acqps +
//1 SYSCLK cycles
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; //end of SOC1 will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
@ -81,7 +99,7 @@ void AdcRun(void)
if(adc_start)
{
adc_start = 0;
AdcaRegs.ADCSOCFRC1.all = 0x0003; //SOC0 and SOC1
AdcaRegs.ADCSOCFRC1.all = 0x0001; //SOC0 (0x0003 = and SOC1)
}
}

View File

@ -134,10 +134,7 @@ void PWMGpioInit(void)//Тут в библиотечном файле вручн
InitEPwm2Gpio();
InitEPwm5Gpio();
InitEPwm7Gpio();
InitEPwm8Gpio();
InitEPwm3Gpio();
// InitEPwm11Gpio();
}
void PWMInitEnable(void)

View File

@ -20,6 +20,7 @@ volatile uint16_t counter2=0 ;
volatile uint16_t testMode = 0;
uint16_t BisscPwrOn = 1;
uint16_t BrakeOn = 0;
void frmmstr_run(void)
{
@ -71,6 +72,15 @@ static uint16_t diod = 0;
{
GpioDataRegs.GPADAT.bit.GPIO21 = 0;
}
if(BrakeOn)
{
GpioDataRegs.GPADAT.bit.GPIO14 = 1;
}
else
{
GpioDataRegs.GPADAT.bit.GPIO14 = 0;
}
//Gpio95out(Rele);
//if(vectorReleOn()) GpioTurnOnRele;
//else GpioTurnOffRele;
@ -81,7 +91,7 @@ static uint16_t diod = 0;
fault_read_ports();
}else{
buttonsDisp();
//ScreenDisp();
ScreenDisp();
}
}