Bool data type in AVRGCC, the AVRStudio IDE detects bool as a keyword but throws a compile error.
In some circumstances, the compiler-generated prologue and epilogue of the ISR might not be optimal for the job, and a manually defined ISR could be considered particularly to speedup the interrupt handling.This can be done using the ISR_NAKED attribute to the ISR() macro. Note that the compiler does not generate anything as prologue or epilogue, so the final reti() must be provided by the actual implementation. SREG must be manually saved if the ISR code modifies it, and the compiler-implied assumption of __zero_reg__ always being 0 could be wrong (e. g. when interrupting right after of a MUL instruction).
bool exists in the current ANSI C - C99, but not in C89/90.
In C99 the native type is actually called
_Bool, while bool is a standard library macro defined in stdbool.h (which expectedly resolves to _Bool). Objects of type _Bool hold either 0 or 1, while true and false are also macros from stdbool.h.
AVR GCC User Defined Data Types
User types
C language allows defining user types. For this typedef keyword is used:
typedef unsigned char byte; //create byte type
typedef unsigned int word; //create word type
In other words defining custom types description structure is used:
typedef standard_type custom_type;
WinAVR compiler has predefined custom types:
typedef signed char int8_t; //located in header file inttypes.h
typedef unsigned char uint8_t; //located in header file inttypes.h
typedef int int16_t; //located in header file inttypes.h
typedef unsigned int uint16_t; //located in header file inttypes.h
typedef long int32_t; //located in header file inttypes.h
typedef unsigned long uint32_t; //located in header file inttypes.h
typedef long long int64_t; //located in header file inttypes.h
typedef unsigned long long uint64_t; //located in header file inttypes.h
typedef struct {int quot; int rem} div_t; //located in header file stdlib.h. It is used for standard function ldiv();
14th April
i was trying to copy some Aurduino libraries to AVRGCC , the functions digitalPinToPort(), digitalPinToPCMSK() are seems usefull but i guess these subroutines should be compile time only it will save both code space, CPU ticks and so the power consumption.
So can be these subroutines can be preprocessor subroutines only. well they have conditional statements in C like #if and #endif
18th April
Interrupt routines in C, there is no standard method defined for interrupts in the C99 standards.
for example PIC compilors use
static void interrupt isr(void)
{
if(T0IF)
{
Timer 0 interrupt;
}
if(TMR1IF)
{
Timer 1 interrupt;
}
if(CCP2IF)
{
Capture interrupt;
}
}
and avrgcc
#include <avr/interrupt.h> ISR(ADC_vect) { // user code here }
ISR(TIMER1_OVF_vect, ISR_NAKED) { PORTB |= _BV(0); // results in SBI which does not affect SREG reti(); }
References:
IAR
IAR

Comments
Post a Comment