AVR c compiler user manual

hgmjr

Joined Jan 28, 2005
9,027
Quite a few actually since you can set the number of counts between timer interrupts by using the CTC mode (Clear Timer on Compare) for the timer used.

hgmjr
 

Thread Starter

mik3

Joined Feb 4, 2008
4,843
I think PICs are superior on PWM because you have much more options for the PWM frequency. I start thinking that PICs are better than AVRs.
 

hgmjr

Joined Jan 28, 2005
9,027
At least you are taking the time to investigate both. Once you have played with the AVR you will be able to speak from first hand experience.

hgmjr
 

Thread Starter

mik3

Joined Feb 4, 2008
4,843
At least you are taking the time to investigate both. Once you have played with the AVR you will be able to speak from first hand experience.

hgmjr
This is true. Both have their plus and minus. For example PICs offer a wide range of PWM frequencies but all the PWM channels have the same frequency (as far as I have seen). With some AVRs you can have two PWM channels with different frequencies.

In my opinion you have to be able to use both PICs and AVRs and choose the proper one depending on the application.

What do you think?

Do you have experience with PICs?
 

hgmjr

Joined Jan 28, 2005
9,027
You're right about using the device that constitutes the best fit for the application.

Both have their advantages and disadvantages. I would imagine that the differences are very subtle and in the end the choice of which to use will be largely based on the designer's comfort level with the device chosen.

I think when it comes to the AVR's PWM flexibility you will find that it differs very little from the PIC. The AVR supports a very wide range of PWM frequencies. In the end all PWM implementations are very similar.

I like the AVR's choice of FAST PWM mode as well as what is term phase-correct PWM.

hgmjr
 

hgmjr

Joined Jan 28, 2005
9,027
The FAST PWM is a single slope PWM and is useful in designing switchmode power supplies while the Phase-Correct PWM is a dual-slope PWM which is typically used for motor speed control.

Take a look at the AVR datasheet for a more detail explanation of the differences in the two PWM modes.

hgmjr
 

nanovate

Joined May 7, 2007
666
Yes I found that. However, I wanted to ask about Codevision and not GNU (mistake).

Does anyone know if Codevision has a delay_ms() function?
Similar to WinAVR :

Rich (BB code):
#include <delay.h>
#include <mega8.h>

/*if not defined in the Project-Configure-C Compiler menu
xtal frequency needs to be defined.These delay functions 
need to know the clock speed. Also you have to disable
interrupts for their timing to be accurate.*/

#define xtal 8000000L

int main(void)
{
   unsigned int my_delay = 100;

   //disable interrupts
   #asm("cli");

   //do delay of 100 milliseconds
   delay_ms(my_delay);

   //do delay of 100 microseconds
   delay_us(my_delay);

   //re-enable interrupts
   #asm("sei");

   while(1);
}
 

Thread Starter

mik3

Joined Feb 4, 2008
4,843
Finally, I have understood that the GNU compiler does not use specific commands to set the PWM (for example) like CCS but you assign values to the registers directly.
This is more difficult to remember but it is possible to learn it.
 

AlexR

Joined Jan 16, 2008
732
GCC in common with most other compilers expects you to know how your microcontroller operates and what registers have to be configured for you program to work.

CCS for the PIC is a C-like compiler that is rich in library functions that hide a lot of the basic register setup detail from the user. The up side of this is fast code development without the need to learn anything about the internal operation of the PIC.
The down side is, without a knowledge of the PIC internals your are limited to using the supplied library functions.

An even bigger problem is that because CSS code relies so heavily on its library functions, code written for CSS not easily ported to other C compilers.
 

hgmjr

Joined Jan 28, 2005
9,027
GCC in common with most other compilers expects you to know how your microcontroller operates and what registers have to be configured for you program to work.

CCS for the PIC is a C-like compiler that is rich in library functions that hide a lot of the basic register setup detail from the user. The up side of this is fast code development without the need to learn anything about the internal operation of the PIC.
The down side is, without a knowledge of the PIC internals your are limited to using the supplied library functions.

An even bigger problem is that because CSS code relies so heavily on its library functions, code written for CSS not easily ported to other C compilers.
This is information about CCS compiler that is good to know.

hgmjr
 

Thread Starter

mik3

Joined Feb 4, 2008
4,843
I noticed that AlexR because by assign values to the registers directly I could compile more or less the same code with three different AVR C compilers.
 
Top