Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Simulation using Piccolo (TMS320f28027pt) in Proteus 8.8

Status
Not open for further replies.

u_nes

Newbie level 1
Joined
May 14, 2019
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
Algeria
Activity points
16
Hello,

I am trying to do a simulation using Piccolo tms320f28027pt but i had a problem running any program successfully.

I wrote the bellow code (just to generate a pwm) and i loaded all necessary source/header files from CCS project (see image) into VSM.

project.PNG

Code:
/* Main.c file generated by New Project wizard
 *
 * Created:   Tue May 14 2019
 * Processor: TMS320F28027PT
 * Compiler:  CodeComposer for Piccolo
 */

#include "DSP28x_Project.h"

// Prototype statements for functions found within this file.
void InitEPwm1Example(void);


// Global variables used in this example

// Configure the period for each timer
#define EPWM1_TIMER_TBPRD  30000                 //1Hz
#define EPWM1_CMPA     EPWM1_TIMER_TBPRD/2       // 20% duty cycle




void main(void)
{
// WARNING: Always ensure you call memcpy before running any functions from RAM
// InitSysCtrl includes a call to a RAM based function and without a call to
// memcpy first, the processor will go "into the weeds"
   #ifdef _FLASH
    memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
   #endif

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the f2802x_SysCtrl.c file.
   InitSysCtrl();



// Step 2. Initialize GPIO:
// This example function is found in the f2802x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();  // Skipped for this example

// For this case just init GPIO pins for ePWM1, ePWM2, ePWM3
// These functions are in the f2802x_EPwm.c file
   InitEPwm1Gpio();

  //SysCtrlRegs.CLKCTL.bit.XTALOSCOFF=0;
// Step 4. Initialize all the Device Peripherals:
// Not required for this example

// For this example, only initialize the ePWM

   EALLOW;
   SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
   EDIS;

   InitEPwm1Example();


   EALLOW;
   SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
   EDIS;


// Step 6. IDLE loop. Just sit and loop forever (optional):



   //select channel 2

   //gpio3 2sec period.......... gpio4 4sec period

       for (;;){
         
       }
}




void InitEPwm1Example()
{
   // Setup TBCLK
   EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count up
   EPwm1Regs.TBPRD = EPWM1_TIMER_TBPRD;       // Set timer period
   EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE;    // Disable phase loading
   EPwm1Regs.TBPHS.half.TBPHS = 0x0000;       // Phase is 0
   EPwm1Regs.TBCTR = 0x0000;                  // Clear counter
   EPwm1Regs.TBCTL.bit.HSPCLKDIV = 1;   // Clock ratio to SYSCLKOUT
   EPwm1Regs.TBCTL.bit.CLKDIV = 0;

   // Setup shadow register load on ZERO
   EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
   EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
   EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
   EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;

   // Set Compare values
   EPwm1Regs.CMPA.half.CMPA = EPWM1_CMPA;    // Set compare A value

   // Set actions
   EPwm1Regs.AQCTLA.bit.ZRO = AQ_SET;            // Set PWM1A on Zero
   EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR;          // Clear PWM1A on event A, up count


}


// No more.
//===========================================================================

And the VSM studio output was: Firmware is already compiled, but when i start the simulation nothing is happened (no pwm, just high impedance pin)!! even when i generate the HEX file using CCS and upload it to proteus, i got the same output.

run.PNG

you can see in the simulation log bellow that EPWM1 is OFF!!?

msg.PNG

could someone show me how to fix this problem.



Thanks,
 

Can you post the "InitEPwm1Gpio()" code ?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top