This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2530: Blinking LED on CC2530

Part Number: CC2530

Hello I am new at cc2530 and embedded developing. I wrote a simple code on IAR Workbench that turns on and off a LED. But it doesn't work and I can't find where the ploblem is?

int main( void )
{
                      
  
    halMcuInit();
    //GPIO Settings
     out.port=0;
     out.pin=1;
     out.dir=HAL_DIGIO_OUTPUT;
     out.initval=0;
     out.pin_bm=0x00;
    
    uint16 x=0;
    
    halDigioConfig(&out);
    halDigioSet(&out); 
    
    halMcuWaitMs(500);
 
     while( x<100){

       
       halDigioClear(&out); 

       halMcuWaitMs(500);
       
       halDigioSet(&out); 

       halMcuWaitMs(500);
    x++;
     }
    
}  

  • What is your halDigioConfig, halDigioSet, and halDigioClear?
  • 
    

    I found a library in Zstack examples. These are the functions used in Zstack examples.  

    uint8 halDigioSet(const digioConfig* p)
    {
       if (p->dir == HAL_DIGIO_OUTPUT)
        {
            switch (p->port)
            {
            case 0: P0 |= p->pin_bm; break;
            case 1: P1 |= p->pin_bm; break;
            case 2: P2 |= p->pin_bm; break;
            default: return(HAL_DIGIO_ERROR);
            }
            return(HAL_DIGIO_OK);
        }
        return(HAL_DIGIO_ERROR);
    }
    
    uint8 halDigioClear(const digioConfig* p)
    {
       if (p->dir == HAL_DIGIO_OUTPUT)
        {
            switch (p->port)
            {
            case 0: P0 &= ~p->pin_bm; break;
            case 1: P1 &= ~p->pin_bm; break;
            case 2: P2 &= ~p->pin_bm; break;
            default: return(HAL_DIGIO_ERROR);
            }
            return(HAL_DIGIO_OK);
        }
        return(HAL_DIGIO_ERROR);
    }
    
    typedef struct {
        uint8 port;     // port number
        uint8 pin;      // pin number
        uint8 pin_bm;   // pin bitmask
        uint8 dir;      // direction (input or output)
        uint8 initval;  // initial value
    } digioConfig;

  • Since you set p->pin_bm to 0, I don’t see why halDigioSet would make any effect to IO pin.
  • Where you able to get this to work? If not, I recommend you take a look at the following examples:
    www.ti.com/.../swrc135
    BR
    Siri