This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I want to create a sin graph of RampGen so I used the lib file inside of TI. (/cfs-file/__key/communityserver-discussions-components-files/171/SolarLib.pdf Page 157). I tried to use CpuTimer0 as an interrupt and with every interrupt it should have created a ramp. After that, I took the sin of the function. However, I can not get the correct graph. Also, I am not sure If I create the Ramp graph right. I researched the TI sources and I could not solve it. I put my code down and hope you can show me the parts that should be corrected. Also, for these values what should I enter into graph properties? If you want, I can add the full file as a zip file and put the graph results.
MAIN FILE:
#include "Lab.h" // Main include file
#include "Solar_IQ.h"
//--- Global Variables
// I used a buffer to get the correct result. I named that AdcBuf1IQ but it is not about ADC it is just a name. I did not change too much from previous examples.
Uint16 AdcBuf1[ADC_BUF_LEN]; // ADC data buffer allocation
_iq AdcBuf1IQ[ADC_BUF_LEN]; // ADC data buffer allocation - IQ
long GlobalQ = GLOBAL_Q; // IQmath debug support
RAMPGEN_IQ Ramp;
/**********************************************************************
* Function: main()
*
* Description: Main function for C28x
**********************************************************************/
void main(void)
{
//--- CPU Initialization
InitSysCtrl(); // Initialize the CPU (FILE: SysCtrl.c)
InitGpio(); // Initialize the shared GPIO pins (FILE: Gpio.c)
InitPieCtrl(); // Initialize and enable the PIE (FILE: PieCtrl.c)
InitWatchdog(); // Initialize the Watchdog Timer (FILE: WatchDog.c)
//--- Peripheral Initialization
InitAdc(); // Initialize the ADC (FILE: Adc.c)
InitEPwm(); // Initialize the EPwm (FILE: EPwm.c)
InitECap(); // Initialize the ECap (FILE: ECap.c)
//RAMPGEN Variables
RAMPGEN_IQ_init(&Ramp);
Ramp.Freq = _IQ24(90);
Ramp.StepAngleMax = _IQ24(1.0/1000);
CpuTimer0.InterruptCount = 0;
//LEDcount=0;
DINT; // Disable CPU Interrupts
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.TINT0 = &TINT0_ISR;
EDIS; // This is needed to disable write to EALLOW protected registers
//CPU Configuration//
InitCpuTimers();
ConfigCpuTimer(&CpuTimer0, 90,1000000); //90 MHz, 500 000 uSecond
// Use write-only instruction to set TSS bit = 0
CpuTimer0Regs.TCR.all = 0x4000;
PieCtrlRegs.PIEIER1.bit.INTx7 = 1; /
IER |= M_INT1;
EINT;
ERTM;
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.TINT0 = &TINT0_ISR;
EDIS; // This is needed to disable write to EALLOW protected registers
//--- Main Loop
while(1) // endless loop - wait for an interrupt
{
asm(" NOP");
}
} //end of main()
/*** end of file *****************************************************/
ISR file;
interrupt void TINT0_ISR(void) // PIE1.7 @ 0x000D4C TINT0 (CPU TIMER 0)
{
CpuTimer0.InterruptCount++;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Must acknowledge the PIE group
static _iq *AdcBuf1IQPtr = AdcBuf1IQ; // Pointer to ADC data buffer
extern RAMPGEN_IQ Ramp;
RAMPGEN_IQ_MACRO(Ramp);
//--- Manage the ADC registers
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Clear ADCINT1 flag
*AdcBuf1IQPtr++ = Ramp.Out; // When I want to see sin graph of it, I change that line to ' AdcBuf1IQPtr++ = _IQsinPU(Ramp.Out) '.
}
We have used this in TI reference designs. So pls check TIDA-010210 or TIDA-01606 for sine wave generation using the RAMP GEN module. Complete documentation of the usage of this module is also provided there.
Shamim
Thank you for your reply. These references use CLA while I am trying to use IQ as you can understand from my code. So can you check my code and tell me if I do a logical mistake in the code or where is the part that needed to be corrected?
These references shows both CPU or CLA based code, or at least it shows the CPU code.
You dont need IQ math for C28x. Use the floating point version of the code.
Shamim
I don't think you understand what I meant. I wanted to do IQ math that's the purpose of my work. Also, references did not help me a lot.
Hello, I also got same situation. ıf you can check the code and help us, we would be glad.
If IQ math is the purpose of your work, please start with the simpler examples in our IQ math library.
With C28x MCUs you don't need to use IQ math. But if IQ math is something you are interested in then you can see our examples.
Shamim
Ugur,
The library for which you're seeking support is part of ControlSUITE, which is legacy software that we don't actively support.
Have you tried using the DigitalPower SDK, which has a rampgen utility in
C2000Ware_DigitalPower_SDK_<version_number>\libraries\utilities\rampgen\include
Thanks,
Sira