PWM ATtiny13 does not work

General discussion on mikroPascal PRO for AVR.
Post Reply
Author
Message
shtela
Posts: 7
Joined: 24 Oct 2014 04:06
Location: Ukraine, Zaporozhye

PWM ATtiny13 does not work

#1 Post by shtela » 24 Oct 2014 04:23

Please help solve the following problem - PWM ATtiny13 does not work.
Program code:

program UPS_12_220V_ATTiny13_v1;
Label L1;
Var i:byte;

Procedure INIT_PORT;
Begin
DDRB.0:=1;
end;

begin { Main program }
INIT_PORT;
PWM_Init(_PWM_FAST_MODE,_PWM_PRESCALER_1,_PWM_NON_INVERTED,0);
PWM_Start;

L1:
For i:=0 to 255 do begin
PWM_Set_Duty(i);
delay_us(34);
end;
For i:=254 downto 0 do begin
PWM_Set_Duty(i);
delay_us(34);
end;
PORTB.3:=1;

goto L1;

end.

In Proteus shows that the PWM pulses at pin B.0 not.
How do I fix this problem.

shtela
Posts: 7
Joined: 24 Oct 2014 04:06
Location: Ukraine, Zaporozhye

Re: PWM ATtiny13 does not work

#2 Post by shtela » 25 Oct 2014 03:42

the question is removed - I installed mikropaskal version 6.0.0 and it worked

shtela
Posts: 7
Joined: 24 Oct 2014 04:06
Location: Ukraine, Zaporozhye

Re: PWM ATtiny13 does not work

#3 Post by shtela » 28 Oct 2014 06:01

Good day.
Library PWM works only with the conclusion OC0A. How can I configure the PWM on pin OC0B?

The code of the program:

program UPS_12_220V_ATTiny13_v1;
Label L1;
Var i:byte;
Procedure INIT_PORT;
Begin
DDRB.0:=1;
DDRB.1:=1;
end;

begin
INIT_PORT;
PWM1_Init(_PWM1_FAST_MODE,_PWM1_PRESCALER_1,_PWM1_NON_INVERTED,0);
PWM1_Start;

L1:

For i:=0 to 255 do begin
PWM1_Set_Duty(i);
delay_us(44);
end;

For i:=255 downto 0 do begin
PWM1_Set_Duty(i);
delay_us(44);
end;

goto L1;
end.

Post Reply

Return to “mikroPascal PRO for AVR General”