hello There,
I am trying to control my AD9361 RF Transceiver device using the driver availale on GitHub (no-OS_R2021) and using petalinux 2021.2 OS.
i am able to Control the LO frequency but not able to increase or decrease the attenuation its always visiable fix ( -40dBm).
trying to Control Attenuation via using wrapper function "ad9361_set_tx_attenuation(ad9361_phy,0,set_attenuation_mdb);"
cnt = 0; /* * Set the transmit attenuation for the selected channel. * @param phy The AD9361 current state structure. * @param ch The desired channel number (TX1, TX2). * Accepted values in 2x2 mode: * TX1 (0) * TX2 (1) * Accepted values in 1x1 mode: * TX1 (0) * @param attenuation_mdb The attenuation (mdB). Example: 10000 (10 dB) * @return 0 in case of success, negative error code otherwise. int32_t ad9361_set_tx_attenuation (struct ad9361_rf_phy *phy, uint8_t ch, uint32_t attenuation_mdb) */ printf("\n User Defined Attenuation via wrapper..........\n"); set_attenuation_mdb = 0; while(cnt<=10) { printf("#.Eneter the Attenuation value : "); scanf("%" SCNu64,&set_attenuation_mdb); printf("16. Setting tx_attenuation= %d \n",set_attenuation_mdb); ret_val = ad9361_set_tx_attenuation(ad9361_phy,0,set_attenuation_mdb); printf("ret_val (ad9361_set_tx_attenuation ch-0) = %d \n",ret_val); ret_val = ad9361_set_tx_attenuation(ad9361_phy,1,set_attenuation_mdb); printf("ret_val (ad9361_set_tx_attenuation ch-1) = %d \n",ret_val); cnt++; no_os_mdelay(500); }
then i have tried control using direct writing to SPI registers
writing 255 ot user define data on address 0x073 (first 8 bit) and at address 0x074 (last 9 bit) along with tried both Setting and resetting bit no 6 of address 0x077
and also setting and resseting bit no 6 of address 0x07C.
cnt = 0; printf("\n User Defined Attenuation via Register..........\n"); while(cnt<=5) { ret_val = ad9361_spi_read(ad9361_phy->spi,REG_TX1_ATTEN_0);//,Atten_Config1); printf("READ: ret_val (REG_TX1_ATTEN_0,Atten_Config1) = %d \n",ret_val); ret_val = ad9361_spi_read(ad9361_phy->spi,REG_TX1_ATTEN_1);//,Atten_Config2); printf("READ: ret_val (REG_TX1_ATTEN_1,Atten_Config2) = %d \n",ret_val); ret_val = ad9361_spi_read(ad9361_phy->spi,REG_TX_ATTEN_OFFSET);//,Atten_Config3); printf("READ: ret_val (REG_TX_ATTEN_OFFSET,Atten_Config3) = %d \n\n",ret_val); ret_val = ad9361_spi_read(ad9361_phy->spi,REG_TX2_DIG_ATTEN);//,Atten_Config4); printf("READ: ret_val (REG_TX2_DIG_ATTEN,Atten_Config4) = %d \n\n",ret_val); printf("#.Eneter the REG_TX1_ATTEN_0 for register Atten_Config1: "); scanf("%" SCNu32,&Atten_Config1); printf("# Setting REG_TX1_ATTEN_0= %d \n",Atten_Config1); printf("#.Eneter the REG_TX_ATTEN_OFFSET for register Atten_Config3: "); scanf("%" SCNu32,&Atten_Config3); printf("# Setting REG_TX_ATTEN_OFFSET = %d \n",Atten_Config3); printf("#.Eneter the REG_TX2_DIG_ATTEN for register Atten_Config4: "); scanf("%" SCNu32,&Atten_Config4); printf("# Setting REG_TX2_DIG_ATTEN = %d \n",Atten_Config4); ret_val = ad9361_spi_write(ad9361_phy->spi,REG_TX1_ATTEN_0,Atten_Config1); printf("ret_val (REG_TX1_ATTEN_0,Atten_Config1) = %d \n",ret_val); ret_val = ad9361_spi_write(ad9361_phy->spi,REG_TX1_ATTEN_1,Atten_Config2); printf("ret_val (REG_TX1_ATTEN_1,Atten_Config2) = %d \n",ret_val); ret_val = ad9361_spi_write(ad9361_phy->spi,REG_TX_ATTEN_OFFSET,Atten_Config3); printf("ret_val (REG_TX_ATTEN_OFFSET,Atten_Config3) = %d \n\n",ret_val); ret_val = ad9361_spi_write(ad9361_phy->spi,REG_TX2_DIG_ATTEN,Atten_Config4); printf("ret_val (REG_TX2_DIG_ATTEN,Atten_Config4) = %d \n\n",ret_val); cnt++; no_os_mdelay(500); }
return value for both read and write is zero (no issue observed), but still not able to increase or decrease the attenuation.
please help me where i am wrong .
regards