how to assign array of pins

Help
2012-07-24
2013-03-12
  • Sixth sense
    Sixth sense
    2012-07-24

    Hi All!

    newbie here .

    is it possible to put the pins assignment on array?
    I would like to do operations on several pins but not necessarily on the same port.
    example is i would like to NOT on combination of ports depending on user input and OR the others.
    I think it would be convenient if I could just call them  myPORTS,myPORTS,myPORTS, … which refers to any pre-assigned pin.

    Here is the concept that I want to do, but obviously it does not compile

    #define __16f690 
    #include <pic16f690.h>
    #include <stdint.h> 
    /* Setup chip configuration */ 
    typedef unsigned int config; 
    config __at 0x2007 __CONFIG = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF; 
    unsigned char* rows[2]={RA0,RC0};
     int i=0;
    main (void)
    {
        TRISA = 0; 
        PORTC = 0;
    
        while (1) 
        { 
            for(i=0;i<=1;i++)
            {
                rows[i] ^=0b11111111;       
            }
    
        } 
    }
    

    Thanks

     
  • Sixth sense
    Sixth sense
    2012-07-24

    erratum

    rows ^=0b11111111;
    

    should be like

    rows[i] ^=0b11111111;
    
     
  • Sixth sense
    Sixth sense
    2012-07-24

    oooppppsss…

    rows ^=0b11111111;

    should be

    rows _ ^=0b11111111;

    the code tag is removing the  array index in rows

    sorry ._