bit fields using S32_Design for register bit access

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

bit fields using S32_Design for register bit access

699 次查看
InHome
Contributor III

Hello,

I have a project already done using access with GPIO and Register using the Bit field. I want to integrate a part of this project using a project that uses the SDK and code generation.

How I could generate the MPC5748G.h file with the right mapping memory?

i.e:

 

PIT->TIMER.TCTRL.B.TEN

 

Is it possible to do this with the S32Design and component inspector?

Thank you in advance,

S.Tarik 

0 项奖励
2 回复数

676 次查看
InHome
Contributor III

Hello Ege,

My application could not be easy to integrate because I don't find this in S32_Design,

in the MCP5748G.h I don't find this:

 

 

struct PIT_tag {
  union {                              /* PIT Module Control Register */
    vuint32_t R;
    struct {
      vuint32_t  :29;
      vuint32_t MDIS_RTI:1;            /* Module Disable - RTI section */
      vuint32_t MDIS:1;                /* Module Disable - (PIT section) */
      vuint32_t FRZ:1;                 /* Freeze */
    } B;
  } MCR;

  uint8_t PIT_reserved0[236];
  union {                              /* Timer Load Value Register */
    vuint32_t R;
    struct {
      vuint32_t TSV:32;                /* Timer Start Value */
    } B;
  } RTI_LDVAL;

  union {                              /* Current Timer Value Register */
    vuint32_t R;
    struct {
      vuint32_t TVL:32;                /* Current Timer Value */
    } B;
  } RTI_CVAL;

  union {                              /* Timer Control Register */
    vuint32_t R;
    struct {
      vuint32_t  :30;
      vuint32_t TIE:1;                 /* Timer Interrupt Enable */
      vuint32_t TEN:1;                 /* Timer Enable Bit */
    } B;
  } RTI_TCTRL;

  union {                              /* Timer Flag Register */
    vuint32_t R;
    struct {
      vuint32_t  :31;
      vuint32_t TIF:1;                 /* Timer Interrupt Flag. */
    } B;
  } RTI_TFLG;

  struct {
    union {                            /* Timer Load Value Register */
      vuint32_t R;
      struct {
        vuint32_t TSV:32;              /* Timer Start Value */
      } B;
    } LDVAL;
    union {                            /* Current Timer Value Register */
      vuint32_t R;
      struct {
        vuint32_t TVL:32;              /* Current Timer Value */
      } B;
    } CVAL;
    union {                            /* Timer Control Register */
      vuint32_t R;
      struct {
        vuint32_t  :29;
        vuint32_t CHN:1;               /* Chain Mode */
        vuint32_t TIE:1;               /* Timer Interrupt Enable */
        vuint32_t TEN:1;               /* Timer Enable */
      } B;
    } TCTRL;
    union {                            /* Timer Flag Register */
      vuint32_t R;
      struct {
        vuint32_t  :31;
        vuint32_t TIF:1;               /* Timer Interrupt Flag */
      } B;
    } TFLG;
  } TIMER[16];
};

 

 

This means I have to change all the .R and .B with the PIT_RTI_XXX_TSx macro

How I could use my code with the minimum intervention.

I think I have the new version of the MPC5748G.h because when I imported a project from examples "spi_zx" without code generation I could find the .B and .R unions.

 

 

0 项奖励

681 次查看
egeonurg
Contributor III

egeonurg_1-1654595480041.png

 

This is how the S32_DS access the registers. ( You can take a look at <driver name>_hw_access.h ) 

1) You can integrate your part to the S32DS project easily, including the MPC5748G.h header file.

2) MPC5748G.h already has the right memory mapping, you can check the locations of the registers by comparing them to the Reference Manual. 

3) Also you can find this file in ProjectName/SDK/platform/devices/MPC5748G/include/MPC5748G.h

 

Best Regards

Ege

 

 

0 项奖励