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.

TMS320F28P559SJ-Q1: Writing directly to microcontrolle registers in the code

Part Number: TMS320F28P559SJ-Q1
Other Parts Discussed in Thread: C2000WARE, SYSCONFIG

Tool/software:

Hi, 

I am trying to work on a new Launch pad  and I have set up my code.  However, I could not write directly to the microcontroller register.  

I get this warning message below:

#10247-D: creating output section \"AdccRegsFile\" without a SECTIONS specification",

And the code has no effect.

How do i write directly to the microcontroler register without having to go through the device library.

Thanks

  • Hello,

    I would suggest taking a look at some of our example code in C2000ware. Depending on the style of project (bitfield or driverlib - see explanation here), there are different way to read/write registers directly.

    • Driverlib
      • The .c and .h files in the path:[C2000ware install]\driverlib\f28p55x\driverlib have examples of driverlib read/writes
      • Write example:  HWREGH(base + ECAP_O_ECCTL1) =
        (HWREGH(base + ECAP_O_ECCTL1) & ~(1U << shift)) |
        ((uint16_t)polarity << shift);
      • Read example: uint32_t  count = HWREG(base + ECAP_O_CAP1);
    • Bitfield
      • The .c and .h files in each of the folder in path: C2000ware install]\device_support\f28p55x\examples show examples of bitfield read/writes
      • Write example:  AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
      • Read example:  adcAResults[index++] = AdcaResultRegs.ADCRESULT0;

    Best Regards,

    Delaney

  • Hello Delaney,

    Thanks for the reply.

    This is the way I implemented the direct write to the microcontroller register

    Write to registger line 

                    PieCtrlRegs.PIEACK.all = INTERRUPT_ACK_GROUP10;
    And I copied the f28p55x_globalvariabledefs.c into my project.
     
    I however still got that warning message.  
    I did not see any example for Bitfield type that you refered to your reply.  Can you refer me to a particular example.
    Thanks.
  • Hi Abayomi,

    It looks like you are using bitfield code then. I would suggest starting from one of the example projects in C2000ware or the empty project example (path:  C2000ware install]\device_support\f28p55x\examples) to start with. This will make sure all the include files are already being pulled in correctly. Then, you can make modifications to this project for your specific application.

    Best Regards,

    Delaney 

  • Hi Delaney,

    Thanks for your feed back.

    This above step was what I used at the commencement of my project.

    Does that mean that there is no example in the C2000ware folder?

    Thanks

  • I have seen an example now.  I would update you when its solved.  Thanks

  • Hi,  

    I have not been able to solve it as the examples that use Bitfield did not use sysconfig and the examples with sysconfig did not use Bitfield.  I am using sysconfig for my project.

    I think the problem relates to the linker command files mapping the register address to the microcontrollere itself.

    What else can I try out.  

    Thanks

  • Hi Abayomi,

    I see, I didn’t know you were using Sysconfig. In that case I would suggest using a driverlib style project for your development which has built in Sysconfig support. This is our most user-friendly software. Can you try running one of the examples in: [C2000ware install]\driverlib\f28p55x\examples ?

    Best Regards,

    Delaney

  • HI Delaney,

    Thanks for your reply.  Yes I am using sysconfig for my project.

    I would like to clarify "using a driverlib style project for your development"  in your reply.

    How do I modify my project for the above as my project is already generated?

    Secondly, can you point me to a particular example for this.

    Thanks.

    Best Regards,

    Yomi

  • Hi Yomi,

    How do I modify my project for the above as my project is already generated?

    By this do you mean the Sysconfig selections have already been done or you've already written your application code (in a bitfield format)?

    Best Regards,

    Delaney

  • HI, 

    I mean I have already done my Sysconfig selection and configuration.  I have also written the code that is meant to handle the ISR.

    Thanks

  • Hi Yomi,

    I see, in that case you can easily just copy over the contents of the .syscfg file into the .syscfg file in the new project using right click >> Open With >> Generic Text Editor. I would suggest doing the following:

    1. Import [C2000ware install]\driverlib\f28p55x\examples\empty_project
    2. Copy the contents of your .syscfg file into the c2000.syscfg file in the empty project
    3. Add an include for board.h in the main file and a call to Board_init() if this is not already in the empty project
    4. Copy over your ISR code and convert to driverlib format

    Best Regards,

    Delaney

  • hi,

    Sorry for the late reply.

    I am yet to get it to work. It is strange this important feature is not in the CCS version 20

    Thanks

  • Hi Abayomi,

    What issue are you having exactly? 

    If you want to send me your sysconfig file (.syscfg) and ISR code I can put it together for you if you'd like.

    Best Regards,

    Delaney

  • HI,

    Thanks for the reply.

    I realy want to use direct write to registers as the code runs faster with this.

    This is the preferred way I want to do the direct write to the registers 

    if(AdccRegs.ADCEVTSTAT.bit.PPB2TRIPHI) 

    But I am using the below form 

    uint16_t intStatus = HWREGH((HWREGH(myADCGrpA_BASE + ADC_O_EVTSTAT) >> ((uint16_t)myADCGrpA_ADCAPPB4VacCurr * 4U)) & 0x7U);
    I see this above form a complex way of doing it.
    I would like to do it using the simpler method - (AdccRegs.ADCEVTSTAT.bit.PPB2TRIPHI).
    How can I import the variable names so that i can be recognised by the linker.
    Thanks
  • Hi Abayomi,

    The HWREG accesses should actually run faster as these use compiler intrinsics to look up the register addresses at compile time rather than during runtime. The bitfield style (AdccRegs.ADCEVTSTAT.bit.PPB2TRIPHI) uses structures which take up extra memory on the device and would require extra cycles to access, so this option should have worse performance during runtime.

    Let me know If you’d still prefer to use bitfield style with sysconfig despite this. 

    Best Regards,

    Delaney

  • Hi Delaney,

    Thanks for the reply.  

    I would close the ticket now.

    Best Regards,

    Yomi