Pwm not work

Moderator: Benj

Post Reply
Serhii
Posts: 6
Joined: Sun Jan 20, 2019 7:51 am
Been thanked: 1 time
Contact:

Pwm not work

Post by Serhii »

Hi everyone. There is a problem with compiling the program with the PWM element. Returns lines:
D:\Projects\TRIMMI~1>"C:\PROGRA~2\Flowcode\Common\COMPIL~1\avr\BATCHF~1\..\bin\avr-gcc.exe" -mmcu=atmega328p -Os -ffunction-sections -fdata-sections -funsigned-char -o "D:\Projects\TRIMMI~1\Flowcode1.elf" "D:\Projects\TRIMMI~1\Flowcode1.c" -lm -Wl,-gc-sections
In file included from C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\includes.c:561,
from D:\Projects\TRIMMI~1\Flowcode1.c:249:
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\/AVR\AVR_CAL_PWM.c:110:5: warning: #warning "PWM Channel Uses Resource Timer 0"
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\/AVR\AVR_CAL_PWM.c:495:3: warning: #warning "Period control register not available on target device, period will default to 255 + 1"
What is wrong ?

mnf
Valued Contributor
Valued Contributor
Posts: 1191
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times
Contact:

Re: Pwm not work

Post by mnf »

Hi Serhii,
Please post a copy of your program and details of hardware etc
You can add attachments using the tab just below the message box...

Martin

Serhii
Posts: 6
Joined: Sun Jan 20, 2019 7:51 am
Been thanked: 1 time
Contact:

Re: Pwm not work

Post by Serhii »

Hi Martin. I use chip ATMega 328p (Arduino UNO and Arduino nano). However, as I read in the file CAL_AVR_PWM this chip is not used in it, but only XMEGA and Tiny. Could that be a problem?
Attachments
Flowcode1.fcfx
(10.66 KiB) Downloaded 353 times
Flowcode1.c
(28.37 KiB) Downloaded 308 times
prog.pwm.png
(279.1 KiB) Downloaded 2968 times

mnf
Valued Contributor
Valued Contributor
Posts: 1191
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times
Contact:

Re: Pwm not work

Post by mnf »

Timer 0 is an 8 bit timer.

Using Timer1 (choose a different channel) allows alteration and compiles ok. It may be a bug or it may be because Timer 0 is used for delay timing purposes.

Martin

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Pwm not work

Post by Benj »

Hello,
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\/AVR\AVR_CAL_PWM.c:110:5: warning: #warning "PWM Channel Uses Resource Timer 0"
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\/AVR\AVR_CAL_PWM.c:495:3: warning: #warning "Period control register not available on target device, period will default to 255 + 1"
What is wrong ?
Nothing wrong just a warning that if you try and change the period using the PWM properties or the ChangePeriod component macro that it won't do anything as the "Period control register not available on target device" and the "period will default to 255 + 1"

Basically the channel you have selected uses a timer that doesn't support variable periods. Other channels using other timers will work fine.

Serhii
Posts: 6
Joined: Sun Jan 20, 2019 7:51 am
Been thanked: 1 time
Contact:

Re: Pwm not work

Post by Serhii »

Ok Benj, I will try it in the device.

Serhii
Posts: 6
Joined: Sun Jan 20, 2019 7:51 am
Been thanked: 1 time
Contact:

Re: Pwm not work

Post by Serhii »

Hi Benj. All right, I don't understand why the PWM initially refused to work, may not be the correct parameters set and the warning scared me? Don't know, but now everything works as it should)) Thanks for the help. Have a nice day!

Serhii
Posts: 6
Joined: Sun Jan 20, 2019 7:51 am
Been thanked: 1 time
Contact:

Re: Pwm not work

Post by Serhii »

Hi Martin. All right, may not be the correct parameters set and the warning scared me?)) But now everything works as it should)) Thanks for the help. Have a nice day!

Post Reply