int instance_startcwmode(int chan) { //NOTE: SPI frequency must be < 3MHz //reduce the SPI speed before switching to XTAL SPI_ConfigFastRate(SPI_BaudRatePrescaler_16); //reduce SPI to < 3MHz dwt_configcwmode(chan); //measure the frequency //Spectrum Analyser set: //FREQ to be channel default e.g. 3.9936 GHz for channel 2 //SPAN to 10MHz //PEAK SEARCH return DWT_SUCCESS ; }
void xtalcalibration(void) { int i; uint8 chan = 2 ; uint8 prf = DWT_PRF_16M ; dwt_txconfig_t configTx ; uint8 pow ; //NOTE: SPI frequency must be < 3MHz //reduce the SPI speed before switching to XTAL // // reset device // dwt_softreset(); // // configure TX channel parameters // configTx.PGdly = txSpectrumConfig[chan].PGdelay ; //Assume smart power is disabled - not relevant for XTAL trimming as CW mode pow = txSpectrumConfig[chan].txPwr[prf - DWT_PRF_16M] & 0xFF ; configTx.power = (pow | (pow << 8) | (pow << 16) | (pow << 24)); dwt_configuretxrf(&configTx); dwt_configcwmode(chan); for(i=0; i<=0x1F; i++) { dwt_xtaltrim(i); //measure the frequency //Spectrum Analyser set: //FREQ to be channel default e.g. 3.9936 GHz for channel 2 //SPAN to 10MHz //PEAK SEARCH } return; }
int main() { Xil_ICacheEnable(); Xil_DCacheEnable(); print("---Entering main---\n\r"); { printf("LEDs and switches\r\n"); XGpio_Initialize(&inGpio,XPAR_AXI_GPIO_1_DEVICE_ID); XGpio_Initialize(&outGpio,XPAR_AXI_GPIO_0_DEVICE_ID); XGpio_DiscreteWrite(&outGpio,1,0); // leds off } { printf("Deca SPI test\r\n"); if (0 != openspi()){ printf("Init SPI failed\r\n"); } else { // get switches int sw = XGpio_DiscreteRead(&inGpio,1); XGpio_DiscreteWrite(&outGpio,1,sw); //printf("LED: %x\r\n",XGpio_DiscreteRead(&outGpio,1)); switch (sw & 0x7){ case 1: printf("SS TWR INIT\r\n"); ssTwrInit(); break; case 2: printf("SS TWR RESP\r\n"); ssTwrResp(); break; case 3: printf("Simple TX\r\n"); simpleTx(); break; case 4: printf("Simple RX\r\n"); simpleRx(); break; case 5: printf("TX Wait\r\n"); txWait(); break; case 6: printf("RX Wait\r\n"); rxWait(); break; default: /* Reset and initialise DW1000. */ reset_DW1000(); dwt_initialise(DWT_LOADNONE); /* Configure DW1000. */ printf("UBW configuration sequence\r\n"); dwt_configure(&config); dwt_configuretxrf(&txconfig); /* Activate continuous wave mode. */ dwt_configcwmode(config.chan); /* Wait for the wanted duration of the continuous wave transmission. */ printf("Waiting for UBW continuous wave transmission delay: %ds\r\n",CONT_WAVE_DURATION_MS/1000); deca_sleep(CONT_WAVE_DURATION_MS); /* Software reset of the DW1000 to deactivate continuous wave mode and go back to default state. Initialisation and configuration should be run * again if one wants to get the DW1000 back to normal operation. */ dwt_softreset(); } printf("Deca test done. press any key\r\n"); getchar(); } } print("---Exiting main---\n\r"); Xil_DCacheDisable(); Xil_ICacheDisable(); return 0; }