From 59478f80d8c1fd77fac11d659c60559ce36dd337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Silva?= Date: Wed, 5 Jun 2024 12:18:37 +0100 Subject: [PATCH] exp-mmw: Work on software MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: João Silva --- software/exp/mmw-int/src/adc.c | 2 +- software/exp/mmw-int/src/admv1013.c | 13 +++++++++++++ software/exp/mmw-int/src/admv1014.c | 13 +++++++++++++ software/exp/mmw-int/src/main.c | 10 ++++++---- software/exp/mmw-int/src/port.c | 8 ++++---- 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/software/exp/mmw-int/src/adc.c b/software/exp/mmw-int/src/adc.c index 616b9efe..30644e64 100644 --- a/software/exp/mmw-int/src/adc.c +++ b/software/exp/mmw-int/src/adc.c @@ -184,7 +184,7 @@ uint32_t adc_get_rx_pwr_vdet() { uint16_t usResult = adc_read_rx_pwr_vdet(); - return (uint64_t)usResult * 100000UL * (ADC_RX_PWR_VDET_DIV_RT + ADC_RX_PWR_VDET_DIV_RB) / (ADC_RX_PWR_VDET_DIV_RB * 4095UL); + return (uint64_t)usResult * 1000000UL * (ADC_RX_PWR_VDET_DIV_RT + ADC_RX_PWR_VDET_DIV_RB) / (ADC_RX_PWR_VDET_DIV_RB * 4095UL); } #ifndef ADC_DISABLE_FLOAT diff --git a/software/exp/mmw-int/src/admv1013.c b/software/exp/mmw-int/src/admv1013.c index b86a7dcf..9c4c212c 100644 --- a/software/exp/mmw-int/src/admv1013.c +++ b/software/exp/mmw-int/src/admv1013.c @@ -48,6 +48,19 @@ uint8_t admv1013_init() if(admv1013_get_chip_id() != 0x0A) return 0; + // Test SPI write and reset + uint16_t usValue = admv1013_read_register(ADMV1013_REG_VVA_TEMP_COMP); + + admv1013_write_register(ADMV1013_REG_VVA_TEMP_COMP, 0xE700); + + if(admv1013_read_register(ADMV1013_REG_VVA_TEMP_COMP) != 0xE700) + return 0; + + admv1013_reset(); + + if(admv1013_read_register(ADMV1013_REG_VVA_TEMP_COMP) != usValue) + return 0; + admv1013_write_register(ADMV1013_REG_VVA_TEMP_COMP, 0xE700); // DS recommended value admv1013_rmw_register(ADMV1013_REG_QUAD, ~0x03C0, ADMV1013_REG_QUAD_QUAD_SE_MODE_SE_NEG_DIS); // Single-ended positive LO admv1013_rmw_register(ADMV1013_REG_ENABLE, ~(ADMV1013_REG_ENABLE_MIXER_IF_EN | ADMV1013_REG_ENABLE_DET_EN), ADMV1013_REG_ENABLE_MIXER_IF_EN | ADMV1013_REG_ENABLE_DET_EN); // Enable mixer IF and detector diff --git a/software/exp/mmw-int/src/admv1014.c b/software/exp/mmw-int/src/admv1014.c index 193a7b1c..53791a8a 100644 --- a/software/exp/mmw-int/src/admv1014.c +++ b/software/exp/mmw-int/src/admv1014.c @@ -51,6 +51,19 @@ uint8_t admv1014_init() if(admv1014_get_chip_id() != 0x09) return 0; + // Test SPI write and reset + uint16_t usValue = admv1014_read_register(ADMV1014_REG_VVA_TEMP_COMP); + + admv1014_write_register(ADMV1014_REG_VVA_TEMP_COMP, 0x727C); + + if(admv1014_read_register(ADMV1014_REG_VVA_TEMP_COMP) != 0x727C) + return 0; + + admv1014_reset(); + + if(admv1014_read_register(ADMV1014_REG_VVA_TEMP_COMP) != usValue) + return 0; + admv1014_write_register(ADMV1014_REG_VVA_TEMP_COMP, 0x727C); // DS recommended value admv1014_rmw_register(ADMV1014_REG_QUAD, ~0x03C0, ADMV1014_REG_QUAD_QUAD_SE_MODE_SE_NEG_DIS); // Single-ended positive LO admv1014_rmw_register(ADMV1014_REG_ENABLE, ~(ADMV1014_REG_ENABLE_P1DB_COMPENSATION | ADMV1014_REG_ENABLE_IF_AMP_PD | ADMV1014_REG_ENABLE_BB_AMP_PD | ADMV1014_REG_ENABLE_DET_EN), ADMV1014_REG_ENABLE_P1DB_COMPENSATION | ADMV1014_REG_ENABLE_BB_AMP_PD | ADMV1014_REG_ENABLE_DET_EN); // Enable P1dB Comp., enable IF amp, disable BB amp, enable detector diff --git a/software/exp/mmw-int/src/main.c b/software/exp/mmw-int/src/main.c index d3d9f0b7..867bd520 100644 --- a/software/exp/mmw-int/src/main.c +++ b/software/exp/mmw-int/src/main.c @@ -451,7 +451,7 @@ int init() port_init(); // Init GPIOs adc_init(); // Init ADC - sercom0_spi_init(6000000, 0, SERCOM_SPI_MSB_FIRST, 1, 1); + sercom0_spi_init(3000000, 0, SERCOM_SPI_MSB_FIRST, 1, 1); sercom2_i2c_master_init(SERCOM_I2C_FAST, SERCOM_I2C_TRISE_DEFAULT); sercom3_uart_init(500000, SERCOM_USART_INT_CTRLA_DORD_LSB | SERCOM_USART_INT_CTRLA_FORM_USART_FRAME_NO_PARITY | SERCOM_USART_INT_CTRLB_SBMODE_1_BIT | SERCOM_SPIM_CTRLB_CHSIZE_8_BIT, 0, 1); @@ -522,7 +522,7 @@ int init() TX_DIG_PWR_EN(); TX_ANA_PWR_EN(); - delay_ms(5); + delay_ms(50); if(admv1013_init()) { @@ -540,11 +540,11 @@ int init() RX_DIG_PWR_EN(); RX_ANA_PWR_EN(); - delay_ms(5); + delay_ms(50); if(admv1014_init()) { - admv1014_power_down(); + // admv1014_power_down(); DBGPRINTLN_CTX("ADMV1014 rev. %hhu init OK!", admv1014_get_revision()); } @@ -632,6 +632,8 @@ int main() DBGPRINTLN("IOVDD: %u mV", ulIOVDD); DBGPRINTLN("Core: %u mV", ulCoreVDD); DBGPRINTLN("Temp: %d.%02u C", lTemp / 1000, ABS(lTemp % 1000)); + DBGPRINTLN("TX Pwr: %u uV", ulTXPwr); + DBGPRINTLN("RX Pwr: %u uV", ulRXPwr); } } } diff --git a/software/exp/mmw-int/src/port.c b/software/exp/mmw-int/src/port.c index 5a4e8175..8c09b6c7 100644 --- a/software/exp/mmw-int/src/port.c +++ b/software/exp/mmw-int/src/port.c @@ -51,14 +51,14 @@ void port_init() PORT_PERI_MUX_SELECT(0, 5, 3); PORT_REGS->GROUP[0].PORT_PINCFG[5] = PORT_PINCFG_INEN_Msk | PORT_PINCFG_PMUXEN_Msk; PORT_PERI_MUX_SELECT(0, 6, 3); - PORT_REGS->GROUP[0].PORT_PINCFG[6] = PORT_PINCFG_PMUXEN_Msk; + PORT_REGS->GROUP[0].PORT_PINCFG[6] = PORT_PINCFG_DRVSTR_Msk | PORT_PINCFG_PMUXEN_Msk; PORT_PERI_MUX_SELECT(0, 7, 3); - PORT_REGS->GROUP[0].PORT_PINCFG[7] = PORT_PINCFG_PMUXEN_Msk; + PORT_REGS->GROUP[0].PORT_PINCFG[7] = PORT_PINCFG_DRVSTR_Msk | PORT_PINCFG_PMUXEN_Msk; PORT_PERI_MUX_SELECT(0, 8, 3); PORT_REGS->GROUP[0].PORT_PINCFG[8] = PORT_PINCFG_INEN_Msk | PORT_PINCFG_PMUXEN_Msk; PORT_PERI_MUX_SELECT(0, 9, 3); PORT_REGS->GROUP[0].PORT_PINCFG[9] = PORT_PINCFG_INEN_Msk | PORT_PINCFG_PMUXEN_Msk; - PORT_REGS->GROUP[0].PORT_PINCFG[10] = 0; + PORT_REGS->GROUP[0].PORT_PINCFG[10] = PORT_PINCFG_DRVSTR_Msk; PORT_REGS->GROUP[0].PORT_PINCFG[11] = PORT_PINCFG_DRVSTR_Msk; PORT_REGS->GROUP[0].PORT_PINCFG[14] = 0; PORT_REGS->GROUP[0].PORT_PINCFG[15] = 0; @@ -74,7 +74,7 @@ void port_init() PORT_REGS->GROUP[0].PORT_PINCFG[24] = 0; PORT_REGS->GROUP[0].PORT_PINCFG[25] = 0; PORT_REGS->GROUP[0].PORT_PINCFG[27] = 0; - PORT_REGS->GROUP[0].PORT_PINCFG[28] = 0; + PORT_REGS->GROUP[0].PORT_PINCFG[28] = PORT_PINCFG_DRVSTR_Msk; PORT_PERI_MUX_SELECT(0, 30, 6); PORT_REGS->GROUP[0].PORT_PINCFG[30] = PORT_PINCFG_INEN_Msk | PORT_PINCFG_PMUXEN_Msk; PORT_PERI_MUX_SELECT(0, 31, 6);