Hi,
I am programming an Xbee Pro S1 using the SMAC codebase. I have seen that this module has a digital potentiometer used to adjust the output power of the XBee Pro but I am not able to change the value of this potentiometer.
This is the code provided for Xbee Pro to write using SPI the digital potentiometer but is not working:
void POT_Write(UINT8 value) {
while(!SPI1S_SPTEF); //Wait for TX Buffer Empty Flag
PTAD_PTAD3 = 0; //DIG_POT_CS low
SPI1D = value; // Write Addr byte
while (!SPI1S_SPTEF); //Wait again for TX Buffer Empty Flag
//A little time is needed after the data
//is clocked in and before CE is deasserted to allow the POT
//to operate properly. Each nop is based on a 16 Mhz clock.
//The amount of time was empirically determined. A timer would be
//a better option given that the MCU clock could change.
__asm nop; __asm nop; __asm nop; __asm nop; __asm nop;
__asm nop; __asm nop; __asm nop; __asm nop; __asm nop;
// set A3/DIG_POS_~CS high to disable writing to the digital potentiometer
// as CS rises, the digital pot loads its register with the clocked in byte value
PTAD_PTAD3 = 1; //DIG_POT_CS High
}