Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

IAR C - looking for a tutorial

Status
Not open for further replies.

mrcube_ns

Advanced Member level 1
Joined
Apr 10, 2002
Messages
452
Helped
48
Reputation
96
Reaction score
34
Trophy points
1,308
Location
Europe
Activity points
3,814
volatile function in iar

I need it too.

Mr.Cube
 

radu

Member level 2
Joined
May 30, 2001
Messages
51
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Baenre compound, MENZOBERRANZAN
Activity points
398
i've figured it out on my own. It's pretty good and allows for fast development, i've completed an IR comm project since my first posting. For notorious ASM programmers, one easy way to access absolute registers is to define them as volatile i.e. :
__no_init volatile __bank0 unsigned char myReg @ 0x20; // myReg EQU 0x20
For bitwise access i.e. (BSF myReg, 2) you must use a struct:
__no_init volatile __bank0 union
{
unsigned char parityReg;
struct
{
unsigned char parityReg0:1;
unsigned char parityReg1:1;
unsigned char parityReg2:1;
unsigned char parityReg3:1;
unsigned char parityReg4:1;
unsigned char parityReg5:1;
unsigned char parityReg6:1;
unsigned char parityReg7:1;
};
} @ 0x2B;
Variable declarations need not always be declared as volatile but can be declared as local within any other function.
As I kept reading i've used less and less inline asm i.e. asm("CLRW"); The complier is really good and i've found out that you start to think more in C than asm.
Other things that i've stumbled upon are interrupt functions. I remember reading somwhere that a function while in the ISR cannot return a value, so i use an emulated return as follows:
1) declare your function to be called in the ISR as void
2) declare a -bitwise access- RETURN REGISTER as above (this can hold the boolean return status of 8 functions)
3) before 'return' from that function bit set or clear a bit in RETURN REG as required
4) within your ISR check this bit to see the status
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top