замена ацп2 на ацп1

This commit is contained in:
seklyuts 2024-08-23 13:15:23 +03:00
parent 1362b58739
commit 09d1aafce3
4 changed files with 34 additions and 32 deletions

View File

@ -24,15 +24,12 @@
void main(void)
{
InitPerif();
//SciaRegs.SCITXBUF.all = 0xA5;
for(;;)
{
// asm (" NOP");
frmmstr_run();
rele_run();
// Gpio_rainbow(diod);
AdcRun();
BissClkgenRun();
}

View File

@ -1,25 +1,25 @@
/*
* adc_init.c
*
* Created on: 19 äåê. 2023 ã.
* Created on: 19 <EFBFBD><EFBFBD><EFBFBD>. 2023 <EFBFBD>.
* Author: seklyuts
*/
#include "f28x_project.h"
Uint16 AdcbResult0;
Uint16 AdcbResult1;
Uint16 AdcaResult0;
Uint16 AdcaResult1;
int16 ADCdiff;
Uint16 adc_start = 0;
__interrupt void adcb1_isr(void)
__interrupt void adca1_isr(void)
{
AdcbResult0 = AdcbResultRegs.ADCRESULT0;
AdcbResult1 = AdcbResultRegs.ADCRESULT1;
AdcaResult0 = AdcaResultRegs.ADCRESULT0;
AdcaResult1 = AdcaResultRegs.ADCRESULT1;
AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
ADCdiff = AdcbResult0 - AdcbResult1;
ADCdiff = AdcaResult0 - AdcaResult1;
//
// Acknowledge
//
@ -33,27 +33,27 @@ void ADCConfigure(void)
// Map ISR functions
//
EALLOW;
PieVectTable.ADCB1_INT = &adcb1_isr; //function for ADCA interrupt 1
PieVectTable.ADCA1_INT = &adca1_isr; //function for ADCA interrupt 1
PieCtrlRegs.PIEIER1.bit.INTx2 = 1;
PieCtrlRegs.PIEIER1.bit.INTx1 = 1;
IER |= M_INT1;
//
// Write configurations
//
AdcbRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
AdcSetMode(ADC_ADCB, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
//
// Set pulse positions to late
//
AdcbRegs.ADCCTL1.bit.INTPULSEPOS = 1;
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
AdcbRegs.ADCCTL2.bit.SIGNALMODE = 0;
AdcaRegs.ADCCTL2.bit.SIGNALMODE = 0;
//
// Power up the ADC
//
AdcbRegs.ADCCTL1.bit.ADCPWDNZ = 1;
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
//
// Delay for 1ms to allow ADC time to power up
@ -62,15 +62,15 @@ void ADCConfigure(void)
//ADCB
AdcbRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 will convert pin B0
AdcbRegs.ADCSOC0CTL.bit.ACQPS = 14; //sample window is acqps +
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 will convert pin B0
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 14; //sample window is acqps +
//1 SYSCLK cycles
AdcbRegs.ADCSOC1CTL.bit.CHSEL = 1; //SOC1 will convert pin B1
AdcbRegs.ADCSOC1CTL.bit.ACQPS = 14; //sample window is acqps +
AdcaRegs.ADCSOC1CTL.bit.CHSEL = 1; //SOC1 will convert pin B1
AdcaRegs.ADCSOC1CTL.bit.ACQPS = 14; //sample window is acqps +
//1 SYSCLK cycles
AdcbRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag
AdcbRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //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
EDIS;
}
@ -81,7 +81,7 @@ void AdcRun(void)
if(adc_start)
{
adc_start = 0;
AdcbRegs.ADCSOCFRC1.all = 0x0003; //SOC0 and SOC1
AdcaRegs.ADCSOCFRC1.all = 0x0003; //SOC0 and SOC1
}
}

View File

@ -16,7 +16,7 @@ typedef unsigned char uint8_t;
#define GPIO_PIN_SCLA 1 // GPIO number for I2C SCLA
// Макрос для отправки команды на OLED-дисплей
//Макрос для отправки команды на OLED-дисплей
#define SSD1306_WRITECOMMAND(cmd) \
do { \
I2C_TXdata[0] = 0x00; \
@ -44,3 +44,6 @@ typedef enum {
} SSD1306_COLOR_t;
uint8_t SSD1306_Init(void);
int buttonsDisp();
int ScreenDisp();

View File

@ -89,6 +89,8 @@ void InitPerif(void)
FRMUartInit();
ADCConfigure();
#ifdef REF0
temperatureInit();
#else
@ -96,11 +98,11 @@ void InitPerif(void)
#endif
// Enable Timer0
InitCpuTimers();
// Configure CPU-Timer 0, 1, and 2 to interrupt every second:
// 200MHz CPU Freq, 1 second Period (in uSeconds)
//
ConfigCpuTimer(&CpuTimer0, 200, 1000000);
InitCpuTimers();
// Configure CPU-Timer 0, 1, and 2 to interrupt every second:
// 200MHz CPU Freq, 1 second Period (in uSeconds)
//
ConfigCpuTimer(&CpuTimer0, 200, 1000000);
// Enable global Interrupts and higher priority real-time debug events:
//