cancel
Showing results for 
Search instead for 
Did you mean: 

IO bit manip in Cosmic

itamar_nsu
Associate II
Posted on August 29, 2003 at 08:08

IO bit manip in Cosmic

3 REPLIES 3
itamar_nsu
Associate II
Posted on August 27, 2003 at 07:52

Hi,

I'm looking for a way to define the io pins of the st7lite0 as labels. that way i would be able to use a format like:

LED = 1;

LED = 0;

a = LED; etc.

Instead of:

PADR = 0x08;

PADR = 0x00;

a = (PADR & 0x0

>> 3; etc.

is there a way to do it under the Cosmic compiler?

Thanks

parveen
Associate II
Posted on August 28, 2003 at 05:41

Hello,

You can use bitfields for your problem

struct t

{

unsigned char bito:1;

.

.

.

unsigned char bit7:1;

};

@tiny volatile struct t PA @address;

#define LED PA.bit0

and so on you can define all the port bits

But there is a problem in this solution. The code generated with this approach uses bset, breset assembly instructions which are not recommended for I/O port data registers.

Hope this helps,

Regards,

PraveenG
jatin
Associate II
Posted on August 29, 2003 at 08:08

Hello Parveen,

bset, breset instructions can be used for I/O data registers but these has to be used with care when you are using the mixed configuaration for your port (like some as o/p & some as i/p). There is an FAQ available in the knowledgebase explaining how to use bit set & reset instructions.

thanks

jatin