Hello,
I install all analog comparators in main function of example-project "comp_dac_c28". M3 kernal flash project "blinky_dc_m3".
Executing code of C28 project:
main() { // Step 1. Initialize System Control for Control and Analog Subsytems // Enable Peripheral Clocks // This example function is found in the F28M35x_SysCtrl.c file. InitSysCtrl(); // If project is linked into flash, copy critical code sections to RAM. #ifdef _FLASH memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize); #endif // Step 2. Initialize GPIO: // This example function is found in the F28M35x_Gpio.c file and // illustrates how to set the GPIO to it's default state. // InitGpio(); // Skipped for this example EALLOW; //InitComp1Gpio(); // Led GpioCtrlRegs.GPCMUX1.bit.GPIO70 = 0; GpioCtrlRegs.GPCDIR.bit.GPIO70 = 1; GpioDataRegs.GPCDAT.bit.GPIO70 = 1; EDIS; // Step 3. Clear all interrupts and initialize PIE vector table: // Disable CPU interrupts DINT; // Initialize the PIE control registers to their default state. // The default state is all PIE interrupts disabled and flags // are cleared. // This function is found in the F28M35x_PieCtrl.c file. InitPieCtrl(); // Disable CPU interrupts and clear all CPU interrupt flags: IER = 0x0000; IFR = 0x0000; // Initialize the PIE vector table with pointers to the shell Interrupt // Service Routines (ISR). // This will populate the entire table, even if the interrupt // is not used in this example. This is useful for debug purposes. // The shell ISR routines are found in F28M35x_DefaultIsr.c. // This function is found in F28M35x_PieVect.c. InitPieVectTable(); // Interrupts that are used in this example are re-mapped to // ISR functions found within this file. // Step 4. Initialize all the Device Peripherals: // This function is found in F28M35x_InitPeripherals.c // InitPeripherals(); // Not required for this example InitAdc1(); // Step 5. User specific code, enable interrupts: // Comparator 1 (High Level) Comp1Regs.COMPCTL.bit.COMPDACEN = 1; // Enable COMP1 Comp1Regs.COMPCTL.bit.COMPSOURCE = 0; // Use DAC1 as minus input to comparator Comp1Regs.DACVAL.bit.DACVAL = 620; // Set DAC1 to 2.0V Comp1Regs.COMPCTL.bit.CMPINV = 0; // Do not invert comparator output {If (A > B) output high} Comp1Regs.COMPCTL.bit.SYNCSEL = 0; // Asynchronous output // Comparator 2 (High Level) Comp2Regs.COMPCTL.bit.COMPDACEN = 1; // Enable COMP2 Comp2Regs.COMPCTL.bit.COMPSOURCE = 0; // Use DAC2 as minus input to comparator Comp2Regs.DACVAL.bit.DACVAL = 620; // Set DAC2 to 2.0V Comp2Regs.COMPCTL.bit.CMPINV = 0; // Do not invert comparator output {If (A > B) output high} Comp2Regs.COMPCTL.bit.SYNCSEL = 0; // Asynchronous output // Comparator 3 (Low Level) Comp3Regs.COMPCTL.bit.COMPDACEN = 1; // Enable COMP3 Comp3Regs.COMPCTL.bit.COMPSOURCE = 0; // Use DAC3 as minus input to comparator Comp3Regs.DACVAL.bit.DACVAL = 232; // Set DAC3 to 0.75V Comp3Regs.COMPCTL.bit.CMPINV = 1; // Invert comparator output {If (A < B) output high} Comp3Regs.COMPCTL.bit.SYNCSEL = 0; // Asynchronous output // Comparator 4 (Low Level) Comp4Regs.COMPCTL.bit.COMPDACEN = 1; // Enable COMP4 Comp4Regs.COMPCTL.bit.COMPSOURCE = 0; // Use DAC4 as minus input to comparator Comp4Regs.DACVAL.bit.DACVAL = 232; // Set DAC3 to 0.75V Comp4Regs.COMPCTL.bit.CMPINV = 1; // Invert comparator output {If (A < B) output high} Comp4Regs.COMPCTL.bit.SYNCSEL = 0; // Asynchronous output // Comparator 5 (High Level) Comp5Regs.COMPCTL.bit.COMPDACEN = 1; // Enable COMP5 Comp5Regs.COMPCTL.bit.COMPSOURCE = 0; // Use DAC5 as minus input to comparator Comp5Regs.DACVAL.bit.DACVAL = 620; // Set DAC5 to 2.0V Comp5Regs.COMPCTL.bit.CMPINV = 0; // Do not invert comparator output {If (A > B) output high} Comp5Regs.COMPCTL.bit.SYNCSEL = 0; // Asynchronous output // Comparator 6 (Low Level) Comp6Regs.COMPCTL.bit.COMPDACEN = 1; // Enable COMP6 Comp6Regs.COMPCTL.bit.COMPSOURCE = 0; // Use DAC6 as minus input to comparator Comp6Regs.DACVAL.bit.DACVAL = 232; // Set DAC3 to 0.75V Comp6Regs.COMPCTL.bit.CMPINV = 1; // Invert comparator output {If (A < B) output high} Comp6Regs.COMPCTL.bit.SYNCSEL = 0; // Asynchronous output for(;;){ if (Comp1Regs.COMPSTS.bit.COMPSTS || Comp2Regs.COMPSTS.bit.COMPSTS || Comp3Regs.COMPSTS.bit.COMPSTS || Comp4Regs.COMPSTS.bit.COMPSTS || Comp5Regs.COMPSTS.bit.COMPSTS || Comp6Regs.COMPSTS.bit.COMPSTS ) { GpioDataRegs.GPCDAT.bit.GPIO70 = 0; // Led on } else { GpioDataRegs.GPCDAT.bit.GPIO70 = 1; // Led off } } }
This programm work properly, if programm execute with jtag SAU100. But if reset Concerto by off-on power supply of board,
then Comparator Control (COMPCTL) Register bits COMPDACE or CMPINV may not set. This bug not stable, and may appear for anyone Comparator.
For check this I flashed both kernel, made hardware reset, made connect to C28 kernel with use jtag. Result you may see in File attachment .
Next if make reset and restart of jtag, bit is set properly.
This experiment I performed with use Concerto F28M35H52C1 on EvalBoard and with use Concerto F28M35H52C1 on board of our development, and had a similar result
How to set the comparator to make it work properly?