LPCopen sct_11u6x.h is wrong?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPCopen sct_11u6x.h is wrong?

1,339件の閲覧回数
renskessener
Contributor I

Maybe it is the wrong place to start this discussion, but ......

 

In lpc open, lpc_chip_11u6x project, there is an error in sct_11u6x.h, as far as I understand.

 

The OUTPUTDIRCTRL register specifies (for each output) the impact of the counting direction on the meaning of set and clear operations on the output.

For each output there are 2 bits to set that behaviour.

However, the routine specified in sct_11u6x.h  to set that register is:

STATIC INLINE void Chip_SCT_SetoutputdirControl(LPC_SCT_T *pSCT, CHIP_SCT_EVENT_T value)

{

    pSCT->OUTPUTDIRCTRL |= value;

}

There is no reference to the output that is to be controlled, nor any  handling of the 2 bits per output.

 

I think the routine should look like:

STATIC INLINE void Chip_SCT_SetoutputdirControl(LPC_SCT_T *pSCT, CHIP_SCT_OUTPUT_REG_T n, uint8_t value)

{

        pSCT->OUTPUTDIRCTRL |= uint32_t (value << (n << 1));

}

 

Regards

Rens

タグ(2)
0 件の賞賛
返信
3 返答(返信)

1,216件の閲覧回数
renskessener
Contributor I

Hello Isaac,

I am using LPCopen 2.06.

Regards, Rens

0 件の賞賛
返信

1,216件の閲覧回数
isaacavila
NXP Employee
NXP Employee

Hello Rens,

Unfortunately, I am not able to see any Chip_SCT_SetoutputdirControl function neither a CHIP_SCT_OUTPUT_REG_T enum in lpcopen_2_06_lpcxpresso_manley_11u68 or lpcopen_2_06_lpcxpresso_nxp_lpcxpresso_11u68 package.

But supposing that CHIP_SCT_OUTPUT_REG_T is an enum from 0 to 3, your function seems correct, I would only suggest to add a MASK to ensure that value is not greater than 3 and clear corresponding field before updating the new data (in case you want to modify value from XX to 00):

STATIC INLINE void Chip_SCT_SetoutputdirControl(LPC_SCT_T *pSCT, CHIP_SCT_OUTPUT_REG_T n, uint8_t value)

{

    pSCT->OUTPUTDIRCTRL &= ~(0x3 << (n << 1));

    pSCT->OUTPUTDIRCTRL |= uint32_t((value & 0x3) << (n << 1));

}

I hope this can help you!

Regards,

Isaac

0 件の賞賛
返信

1,216件の閲覧回数
isaacavila
NXP Employee
NXP Employee

Hello Rens,

Could you be so kind to tell me which LPCOpen version are you using?

Regards,

Isaac

0 件の賞賛
返信