Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

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
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.
 

what do you mean check the datasheet?
 

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

The register you refer to is

Snap2.jpg

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

you mean like this
SPE 6
???????
 

Yes

Code:
#define SPE 6

but maybe it's already implemented in codevision and you don't need to add it.
 

and one more thing should I define the reg SPCR at first?
 

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).
 
  • Like
Reactions: ghoola

    ghoola

    Points: 2
    Helpful Answer Positive Rating
thank you so much dear alexan_e
 

Which version are you using, is it 2.x or 3.x ?
And which MCU model?
 

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
 

so if i download CV version 2.6 or 3.x everything going to be ok?
 

Yes, these versions include additional headers with definitions for the bit names (e.g. mega32_bits.h)
 
  • Like
Reactions: ghoola

    ghoola

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top