Skip to main content
Visitor II
August 29, 2003
Question

IO bit manip in Cosmic

  • August 29, 2003
  • 3 replies
  • 752 views
Posted on August 29, 2003 at 08:08

IO bit manip in Cosmic

    This topic has been closed for replies.

    3 replies

    Visitor II
    August 27, 2003
    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

    Visitor II
    August 28, 2003
    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
    Visitor II
    August 29, 2003
    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