cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate a 1000Hz signal on PC7 using TIM3 or TIM8 on STM32L476QE 80MHz. Using a prescaler 1000.

Eliso
Associate II

With the SW generated by MX as example I have a timer that seems to work, but not a signal on PC7.

20 REPLIES 20
Sorry, I´m sending as txt file. Em sex., 9 de abr. de 2021 às 18:16, ST Community escreveu:
DavidAlfa
Senior II

sConfigOC.Pulse = 0;

Also, prescaler should be 999.

Shouldn't you put a value here?

Like 50% of the timer period. Whatever, but not 0.

0 will never trigger the OC.

Also, why run the timer at 2KHz to toggle the output and achieve 1KHz.

You can just set it into PWM mode.

Pre=999

Period=79

Pulse=39

Start PWM and it'll be toggling the output at 1KHz.

I test putting sConfigOC.Pulse = 20; but nothing change on PC7. Em sex., 9 de abr. de 2021 às 20:03, ST Community escreveu:

Are you trying to send the registers content through e-mail? Nothing arrived here.

If so, can you please do it through the web interface.

Or just enter it as plain text into the message, once you have it in text form.

JW

I´m sending the register content. Em sáb., 10 de abr. de 2021 às 05:12, ST Community escreveu:
I didn´t forgotten to annex the file. So i´m sending the .txt file with another extension (jpg) Em sáb., 10 de abr. de 2021 às 08:17, Eliso Cavali escreveu:
DavidAlfa
Senior II

Export the project in zip and upload here.

Delete Debug and Release folders, they take a lot of space.

Sending e-mails with attachments to this forum apparently does not work.

Please use the web interface.

JW

memory GPIOC 0x48000800 FFFFBFFF 00000000 00000000 00000000 0x48000810 00000000 00000000 00000000 00000000 0x48000820 30000000 00000000 00000000 00000000 0x48000830 00000000 00000000 00000000 00000000 0x48000840 00000000 00000000 00000000 00000000 0x48000850 00000000 00000000 00000000 00000000 0x48000860 00000000 00000000 00000000 00000000 Memory TIM8 0x40013400 00000001 00000000 00000000 00000000 0x40013410 0003001f 00000000 00000000 00000000 0x40013420 00000000 00000020 000003e8 00000027 0x40013430 00000000 00000000 00000000 00000000 0x40013440 00000000 00008000 00000000 00000001 0x40013450 00000000 00000000 00000000 00000000 0x40013460 00000001 00000001 00000000 00000000 0x40013470 00000000 00000000 00000000 00000000 0x40013480 00000000 00000000 00000000 00000000 0x40013490 00000000 00000000 00000000 00000000 0x400134A0 00000000 00000000 00000000 00000000 0x400134B0 00000000 00000000 00000000 00000000 0x400134C0 00000000 00000000 00000000 00000000 0x400134D0 00000000 00000000 00000000 00000000 0x400134E0 00000000 00000000 00000000 00000000 Em sáb., 10 de abr. de 2021 às 12:53, ST Community escreveu:

GPIOC is OK.

00000001   __IO uint32_t CR1;         /*!< TIM control register 1,                   Address offset: 0x00 */
00000000   __IO uint32_t CR2;         /*!< TIM control register 2,                   Address offset: 0x04 */
00000000   __IO uint32_t SMCR;        /*!< TIM slave mode control register,          Address offset: 0x08 */
00000000   __IO uint32_t DIER;        /*!< TIM DMA/interrupt enable register,        Address offset: 0x0C */
0003001f   __IO uint32_t SR;          /*!< TIM status register,                      Address offset: 0x10 */
00000000   __IO uint32_t EGR;         /*!< TIM event generation register,            Address offset: 0x14 */
00000000   __IO uint32_t CCMR1;       /*!< TIM capture/compare mode register 1,      Address offset: 0x18 */
00000000   __IO uint32_t CCMR2;       /*!< TIM capture/compare mode register 2,      Address offset: 0x1C */
00000000   __IO uint32_t CCER;        /*!< TIM capture/compare enable register,      Address offset: 0x20 */
00000020   __IO uint32_t CNT;         /*!< TIM counter register,                     Address offset: 0x24 */
000003e8   __IO uint32_t PSC;         /*!< TIM prescaler,                            Address offset: 0x28 */
00000027   __IO uint32_t ARR;         /*!< TIM auto-reload register,                 Address offset: 0x2C */
00000000   __IO uint32_t RCR;         /*!< TIM repetition counter register,          Address offset: 0x30 */
00000000   __IO uint32_t CCR1;        /*!< TIM capture/compare register 1,           Address offset: 0x34 */
00000000   __IO uint32_t CCR2;        /*!< TIM capture/compare register 2,           Address offset: 0x38 */
00000000   __IO uint32_t CCR3;        /*!< TIM capture/compare register 3,           Address offset: 0x3C */
00000000   __IO uint32_t CCR4;        /*!< TIM capture/compare register 4,           Address offset: 0x40 */
00008000   __IO uint32_t BDTR;        /*!< TIM break and dead-time register,         Address offset: 0x44 */
00000000   __IO uint32_t DCR;         /*!< TIM DMA control register,                 Address offset: 0x48 */
00000001   __IO uint32_t DMAR;        /*!< TIM DMA address for full transfer,        Address offset: 0x4C */
00000000   __IO uint32_t OR1;         /*!< TIM option register 1,                    Address offset: 0x50 */
00000000   __IO uint32_t CCMR3;       /*!< TIM capture/compare mode register 3,      Address offset: 0x54 */
00000000   __IO uint32_t CCR5;        /*!< TIM capture/compare register5,            Address offset: 0x58 */
00000000   __IO uint32_t CCR6;        /*!< TIM capture/compare register6,            Address offset: 0x5C */
00000001   __IO uint32_t OR2;         /*!< TIM option register 2,                    Address offset: 0x60 */
00000001   __IO uint32_t OR3;         /*!< TIM option register 3,                    Address offset: 0x64 */
                                                                                                 

This is a running timer, but channel 2 is not set to PWM. You need to:

  • set TIM8_CCMR1.OC2M to one of the PWM modes, i.e. to 6 or 7 (0b110 or 0b111)
  • set TIM8_CCER.CC2E in order to enable that channel's output
  • set TIM8_CCR2 to nonzero value less than what's in TIM8_ARR

I don't use Cube so I don't know how to do that in Cube.

JW