PWM on Atmega88

General discussion on mikroPascal for AVR.
Post Reply
Author
Message
vidor
Posts: 4
Joined: 07 Jan 2008 10:35

PWM on Atmega88

#1 Post by vidor » 08 Jan 2008 10:34

Hi all,

I am a new user to the mikroPascal IDE, but I used to program in C and assembler. I want to go over to Pascal language, so I want to try out this mikroPascal but i get troubles right in the beginning :( ...
I tried to test the PWM on an Atmega88 but without any luck.
I get the following errors:
E-3 Identifier 'Pwm_Init' was not declared pwm_test.apas
E-4 Syntax error: Expected 'end' but ':=' found pwm_test.apas
E-3 Identifier 'Pwm_Set_Duty' was not declared pwm_test.apas
E-4 Syntax error: Expected '.' but ';' found pwm_test.apas
E-21 Internal error: E124 pwm_test.apas

I looked in the manual too, to find out the reason for errors and I found the following Requirements:
"You need a CMO module on PORTB to use this library. Check mikroPascal installation folder, subfolder “Examples”, for alternate solutions." :( :!: :?:
Where can I find those alternate solutions?
What I have to do, to get the PWM out from the Atmega88?
I had no problems using Assembler.
Can you help me out?

/Vidor

vidor
Posts: 4
Joined: 07 Jan 2008 10:35

#2 Post by vidor » 09 Jan 2008 11:05

I found that the PWM is not added to Atmega88def file.
I added the pwm, and now I get one error line:
E-1 Error in ASM code: Register is out of range "102" TCCR0

A step forward, but not enough.
I see that is no much here in the forum.
I see a bunch of questions, without answers.
The support is not much to have here :roll:
I hope the software it will do the promised statements.

Vidor

earlyperl
Posts: 23
Joined: 04 Nov 2007 22:51
Location: Germany
Contact:

#3 Post by earlyperl » 09 Jan 2008 16:27

Hi,
try TCCR0A and TCCRA0B and look here:
http://www.atmel.com/dyn/resources/prod ... /2545S.pdf

Best regards
Marco

vidor
Posts: 4
Joined: 07 Jan 2008 10:35

#4 Post by vidor » 09 Jan 2008 16:46

Hi Marco,

I've checked the file Atmega88.apas and I found those resister addresses on the right place and right adresses:
TCCR0B: byte; absolute 0x45; volatile; register;
TCCR0A: byte; absolute 0x44; volatile; register;

So I don't know what could be the next step. I assume that I have to write the code myself, or there is some other choises?

Regards
Vidor

ljmarkus
Posts: 14
Joined: 17 Dec 2007 17:35
Location: Germany

#5 Post by ljmarkus » 10 Jan 2008 19:26

vidor wrote: E-1 Error in ASM code: Register is out of range "102" TCCR0

Vidor
My Setup: All AVR's, SelfBoard, pascal V4.02

vidor
Posts: 4
Joined: 07 Jan 2008 10:35

#6 Post by vidor » 14 Jan 2008 10:04

Hi Marco,

I think there is a missunderstanding.
The code is as follows:

Code: Select all

program pwm_test;
var duty_cycle : byte;
begin
  //PortD.6 will be the outport
  DDRD.5:=1; // Setting direction
  duty_cycle := 30;
  Pwm_Init(PWM_PHASE_CORRECT_MODE, PWM_PRESCALER_1, PWM_NON_INVERTED, duty_cycle);
  while true do
    begin
      Delay_ms(100);
      duty_cycle := duty_cycle + 1;
      Pwm_Set_Duty(duty_cycle);
    end;
end.
What is wrong?
I get the error as I mentioned it:
E-1 Error in ASM code: Register is out of range "102" TCCR0
How can I fix it?

Regards
Vidor

Post Reply

Return to “mikroPascal for AVR General”