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.
Look at the code that controls the LEDs in the hal folder. You'll see exactly how to write the stub function to initialize (set the port direction as in or out), then set or read the value on the port. Search for HAL_TURN_ON_LED1().
I don't know what VDD SW control is, but you should be able to control any port/pin that isn't already connected to external hardware.
Scott
Thanks Scott.
The VDD_SW control is essentially the P1.2, where it is used to turn on/off the power supply for sensors ( motion, light, ...) in the CC2430DB.
In the intialization section for board CC2430DB, it does have the configration for the port P1.2.
/* ----------- Board Initialization ---------- */
#define VDD_SW_BV BV(2)
#define VDD_SW_SBIT P1_2
#define VDD_SW_DDR P1DIR
#define HAL_BOARD_INIT() { \
uint16 i; \
\
SLEEP &= ~OSC_PD; /* turn on 16MHz RC and 32MHz XOSC */\
while (!(SLEEP & XOSC_STB)); /* wait for 32MHz XOSC stable */\
asm("NOP"); /* chip bug workaround */\
for (i=0; i<504; i++) asm("NOP"); /* Require 63us delay for all revs */\
CLKCON = (0x00 | OSC_32KHZ); /* 32MHz XOSC */\
while (CLKCON != (0x00 | OSC_32KHZ)); \
SLEEP |= OSC_PD; /* turn off 16MHz RC */\
\
/* set direction for GPIO outputs */ \
LED1_DDR |= LED1_BV; \
LED2_DDR |= LED2_BV; \
\
/* configure tristates */ \
P2INP |= PUSH2_BV; \
\
/* configure software controlled peripheral VDD */ \
VDD_SW_DDR |= VDD_SW_BV; \
VDD_SW_SBIT = 0; \
}
From above code, the P1.2 is configured as ouput.
Now the problem is I can only set the P1.2 to high level (VDD_SW_SBIT=1), and I cannot set it to low level again by using VDD_SW_SBIT=1 or VDD_SW_SBIT=!!1.
I donnot know where the problem is.