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.

EDIS: Determine state of protected register access



How does one determine the state of protected register access?  Example: a function needs to determine the state of protected register access to decide if EDIS should be invoked or left alone ... EALLOW could have been invoked by the code that called this function.

  • Hi Clyde,

    As far as I know, there is no possibility to see if the protected registers are "EALLOWED" or not. I think it is good practise to always squeeze the code that needs prot register access between EALLOW EDIS. I would have a very bad feeling invoking a function call with protected registers open...

    BR Andreas

  • Hi Andreas,

    I generally use good practices for writing code.  I am trying to find a solution to http://e2e.ti.com/support/microcontrollers/tms320c2000_32-bit_real-time_mcus/f/171/p/95623/334993.aspx#334993 ... one option is to disable the PWM by switching from EPWM1A to GPIO ... although I don't like that approach.  To be on the safe side, I'd want to view the state of the protected register before I take any action.

    Clyde

     

  • Here is a way to retrieve the status of EALLOW.

    //-----------------------------------------------------------------------------
    void main(void)
    {
      Uint16 uiEallowStatus;
      EALLOW;
      uiEallowStatus = gGetEallowStatus();
      EDIS;
      uiEallowStatus = gGetEallowStatus();
    }
    //-----------------------------------------------------------------------------
    //-----------------------------------------------------------------------------
    typedef struct {                                               
    unsigned int SXM:1;       /* 0 Sign Extension Mode Bit 0 R/W*/                         
    unsigned int OVM:1;       /* 1 Overflow Mode Bit 0 R/W*/                                
    unsigned int TC:1;        /* 2 Test Control Bit 0 R/W*/                              
    unsigned int C:1;         /* 3 Carry Bit 0 R/W*/                                    
    unsigned int Z:1;         /* 4 Zero Condition Bit 0 R/W*/                           
    unsigned int N:1;         /* 5 Negative Condition Bit 0 R/W*/                       
    unsigned int V:1;         /* 6 Overflow Condition Bit 0 R/W*/                       
    unsigned int PM:3;        /* 9:7 Product Shift Mode 0 (+1 shift) R/W*/               
    unsigned int OVC_OVCU:6;  /* 15:10 ACC Overflow Counter 0 R/W*/
    }ST0_Register;
    //-----------------------------------------------------------------------------
    typedef struct {                                               
    unsigned int INTM:1;      /* 0 Interrupt Global Mask Bit 1 R/W*/                         
    unsigned int DBGM:1;      /* 1 Debug Enable Mask Bit 1 R/W*/                                
    unsigned int PAGE0:1;     /* 2 PAGE0 Addressing Mode Configuration Bit 0 R/W*/                              
    unsigned int VMAP:1;      /* 3 Vector Map Bit 1 R/W*/                                    
    unsigned int SPA:1;       /* 4 Stack Pointer Alignment Bit 0 R/W*/                           
    unsigned int LOOP:1;      /* 5 Loop Instruction Status Bit 0 R*/                       
    unsigned int EALLOW:1;    /* 6 Emulation Access Enable Bit 0 R/W*/                       
    unsigned int IDLESTAT:1;  /* 7 IDLE Status Bit 0 R*/ 
    unsigned int AMODE:1;     /* 8 Address Mode Bit 0 R/W*/
    unsigned int OBJMODE:1;   /* 9 Object Compatibility Mode Bit 0 R/W*/
    unsigned int rsvd1:1;     /* 10 reserved 0 R/W*/
    unsigned int M0M1MAP:1;   /* 11 M0 And M1 Mapping Mode Bit 1 R/W*/
    unsigned int XF:1;        /* 12 XF Status Bit 0 R/W*/
    unsigned int ARP:3;       /* 15:13 Auxiliary Register Pointer 0 R/W*/
    }ST1_Register;
    //-----------------------------------------------------------------------------
    ST0_Register ST0_REG;
    ST1_Register ST1_REG;
    //-----------------------------------------------------------------------------
    unsigned int gGetEallowStatus(void)
    {
      asm(" MOVW DP,#_ST0_REG");    
      asm(" PUSH ST0");
      asm(" POP @_ST0_REG");

      asm(" MOVW DP,#_ST1_REG");    
      asm(" PUSH ST1");
      asm(" POP @_ST1_REG");

      return ST1_REG.EALLOW;
    }
    //-----------------------------------------------------------------------------