avr programming in AVR Studio and CodeVision

Status
Not open for further replies.

ghoola

Member level 2
Joined
Aug 7, 2013
Messages
43
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Location
india
Visit site
Activity points
352
how can I change this AVR studio code to Codevision code?
Code:
 SPCR = _BV(SPE)|_BV(MSTR)|_BV(SPR1)|_BV(SPR0)
 

The definition of _BV is

Code:
#define _BV(bit) (1 << (bit))

so basically your code is

Code:
SPCR = (1<<SPE) | (1<<MSTR) | (1<<SPR1) | (1<<SPR0);

If the SPE,MSTR,SPR1 and SPR0 bits are not defined in codevision then check the datasheet and either add the definitions or replace them with numbers.
 

The datasheet lists all the registers and the names of each bit of the register

The register you refer to is



So if the definition don't exist in codevision you can either add them or replace the bit names with the bit number
 

I would expect the register names to be already defined.

You can try to compile your code, if any name if undefined you will get an error and then you can fix it.
You can also check the content of the header that codevision attaches in the project (the specific mcu model defines).
 
Reactions: ghoola

    ghoola

    Points: 2
    Helpful Answer Positive Rating
In version 2.03.9 there is only

Code:
sfrb SPCR=0xd;

The bit definitions got added in newer versions, like 2.6 or 3.x
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…