SCT timer on LPC845brk

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

SCT timer on LPC845brk

跳至解决方案
1,530 次查看
tomato
Contributor III

Hi all,

I am trying to program the SCT timer in the LPC845brk to output a PWM waveform to PIO1_0.

Can you help me to understand why the SCTtimer does not run? I see that the counter register keeps staying at zero.

This is my initialization function

tomato_1-1672313973485.png

 

Basically I followed the manual and the AN11538 but there must be still something that I am missing.

Thanks

 

0 项奖励
回复
1 解答
1,504 次查看
tomato
Contributor III

Hi raul,

I managed to fix the problem changing this 

tomato_0-1672399725721.png

 

在原帖中查看解决方案

0 项奖励
回复
5 回复数
1,512 次查看
RaRo
NXP TechSupport
NXP TechSupport

Hello @tomato,

First of all, could you please check if you are having a change in PINASSIGN_DATA[7]?

Replicating your possible error, the PINASSIGN_DATA[7] was not modifying. You should clear the register, and then assign SCT_OUT0 to pin PIO1_0.

Here is an example:

RaulRomero_0-1672348161676.png

Let us know if this helps you.

 

Also, you could try testing the SCT examples in MCUXpresso IDE with the SDK LPC845 or LPC845BREAKOUT.

RaulRomero_1-1672348161679.png

 

RaulRomero_2-1672348161685.png

RaulRomero_3-1672348161690.png

The SCTimer Simple PWM example is a simple demonstration program of the SDK SCTimer driver capability to generate PWM signals.

It may be useful to try it out, and then made some changes according to what you need.

Best regards, Raul.

0 项奖励
回复
1,476 次查看
tomato
Contributor III

Hi @RaRo 

 

I was doing some tests on my code and I discovered that changing this register

SYSCON->SCTCLKDIV=2; // SCT clock divider

does not affect the PWM period that I am generating.

Can you help to understand why ?

I see this in the manual

tomato_0-1672653811493.png

Even if I put zero in this field the PWM keeps working.

 

Best regards

 

0 项奖励
回复
1,466 次查看
RaRo
NXP TechSupport
NXP TechSupport

Hello @tomato,

For modifying the period of the PWM signal, you should change the MATCHREL[0].

RaulRomero_0-1672683451032.png

[AN11538. Chapter 6. Simple PWM]

The SCTCLKDIV may be affecting directly the behavior of the PWM only if you are using CKSEL as 8 or 9.

RaulRomero_1-1672683451035.png

RaulRomero_2-1672683451040.png

[LPC84x User Manual. Chapter 21. SCTimer/PWM. Table 387 SCTimer/PWM CONFIG register]

Regards, Raul.

0 项奖励
回复
1,505 次查看
tomato
Contributor III

Hi raul,

Thanks a lot for the quick and useful reply. 

As you said I forgot to clear the PINASSIGN_DATA[7] register.

However there should be another problem that makes the SCTtimer to not start (COUNT register keeps staying at zero).

tomato_0-1672398483590.png

 

If I try to write to the COUNT register the value is not modified. The SCT clock enable bit is asserted and SCT clocked by main clock

tomato_1-1672398634086.png 

tomato_2-1672398691553.png

What do you think about this? Did I forget anything else in the SCT initialization?

 

Best regards

 

 

0 项奖励
回复
1,505 次查看
tomato
Contributor III

Hi raul,

I managed to fix the problem changing this 

tomato_0-1672399725721.png

 

0 项奖励
回复