#include "xparameters.h" #include #include #include #include #define RDEN 0xFFFFFBFF #define RDDIS 0xFFFFFFFF #define WREN 0xFFFFBFFF #define WRDIS 0xFFFFFFFF #define FFTREAL 0xFFFFF7FF #define FFTIMAG 0xFFFFFFFF #define CAPSTART 0xFFFFFFFF #define CAPSTOP 0xFFFFEFFF #define FFTSTART 0xFFFFFFFF #define FFTSTOP 0xFFFFDFFF #define FFTSEL 0x40000000 #define CAPSEL 0x80000000 int main(void) { long i = 0; long bitinv, tmp, k; char onechar; unsigned long fftreg0; unsigned long fftreg1; unsigned long fftreg2; unsigned long msg2send; int flag; char testchar[10]; int testdata; unsigned short datacount = 0; char msg[]={"XXXXXXXXXXXXXXXXX"}; lcd_init(XPAR_LCD_CONTROLLER_0_BASEADDR); lcd_line(XPAR_LCD_CONTROLLER_0_BASEADDR, 1); lcd_write(XPAR_LCD_CONTROLLER_0_BASEADDR, " Start "); lcd_line(XPAR_LCD_CONTROLLER_0_BASEADDR, 2); lcd_write(XPAR_LCD_CONTROLLER_0_BASEADDR, " Fft250Mon.exe "); fftreg0 = RDDIS & WRDIS & FFTIMAG & CAPSTOP & FFTSTOP; *(volatile unsigned long *)XPAR_FFTRTL_1024_0_BASEADDR = fftreg0; while(1) { onechar = 0; while((onechar = get_char()) == 0 ) {} if(onechar == 'p') { // product name myprint("ACKPNFFT250\r\n"); } else if(onechar == 'c') { // normal injection from A/D fftreg0 = RDDIS & WRDIS & FFTIMAG & CAPSTART & FFTSTOP; *(volatile unsigned long *)XPAR_FFTRTL_1024_0_BASEADDR = fftreg0; flag = 1; while( flag != 0 ) { fftreg1 = *(volatile unsigned long *)(XPAR_FFTRTL_1024_0_BASEADDR+4); flag = fftreg1 & CAPSEL; } lcd_line(XPAR_LCD_CONTROLLER_0_BASEADDR, 2); lcd_write(XPAR_LCD_CONTROLLER_0_BASEADDR, "ready to do FFT "); } else if(onechar == 't') { // inject test data myscan(testchar, 5); testdata = Hex_2_Dec(testchar); bitinv = 0; for( k = 0; k < 10; k++ ) { tmp = 1 << k; if((tmp & datacount) != 0) bitinv += (1 << (9-k)); } fftreg0 = 0xFFFFFC00 | bitinv; fftreg0 = fftreg0 & RDDIS & WREN & FFTREAL & CAPSTOP & FFTSTOP; *(volatile unsigned long *)XPAR_FFTRTL_1024_0_BASEADDR = fftreg0; fftreg2 = 0xFFFF0000 | testdata; *(volatile unsigned long *)(XPAR_FFTRTL_1024_0_BASEADDR+8) = fftreg2; lcd_char_hex2("Ad:", bitinv, " Dt:", testdata, msg); lcd_line(XPAR_LCD_CONTROLLER_0_BASEADDR, 1); lcd_write(XPAR_LCD_CONTROLLER_0_BASEADDR, msg); if(datacount == 1023) { lcd_line(XPAR_LCD_CONTROLLER_0_BASEADDR, 2); lcd_write(XPAR_LCD_CONTROLLER_0_BASEADDR, "ready to do FFT "); } else if(datacount == 0) { lcd_line(XPAR_LCD_CONTROLLER_0_BASEADDR, 2); lcd_write(XPAR_LCD_CONTROLLER_0_BASEADDR, "initializing RAM"); } if(datacount == 1023) datacount = 0; else datacount++; } else if(onechar == 'f') { // FFT execution fftreg0 = RDDIS & WRDIS & FFTREAL & CAPSTOP & FFTSTART; *(volatile unsigned long *)XPAR_FFTRTL_1024_0_BASEADDR = fftreg0; flag = 1; while( flag != 0 ) { fftreg1 = *(volatile unsigned long *)(XPAR_FFTRTL_1024_0_BASEADDR+4); flag = fftreg1 & FFTSEL; } lcd_line(XPAR_LCD_CONTROLLER_0_BASEADDR, 2); lcd_write(XPAR_LCD_CONTROLLER_0_BASEADDR, "FFT finished "); datacount = 0; } else if(onechar == 'r') { // read real RAM for(i = 0; i < 1024; i++) { fftreg0 = 0xFFFFFC00 | i; fftreg0 = fftreg0 & RDEN & WRDIS & FFTREAL & CAPSTOP & FFTSTOP; *(volatile unsigned long *)XPAR_FFTRTL_1024_0_BASEADDR = fftreg0; fftreg1 = *(volatile unsigned long *)(XPAR_FFTRTL_1024_0_BASEADDR+4); msg2send = fftreg1 & 0x0000FFFF; put_char_hex(msg2send); } lcd_line(XPAR_LCD_CONTROLLER_0_BASEADDR, 2); lcd_write(XPAR_LCD_CONTROLLER_0_BASEADDR, "Real Spec dumped"); } else if(onechar == 'i') { // read imag RAM for(i = 0; i < 1024; i++) { fftreg0 = 0xFFFFFC00 | i; fftreg0 = fftreg0 & RDEN & WRDIS & FFTIMAG & CAPSTOP & FFTSTOP; *(volatile unsigned long *)XPAR_FFTRTL_1024_0_BASEADDR = fftreg0; fftreg1 = *(volatile unsigned long *)(XPAR_FFTRTL_1024_0_BASEADDR+4); msg2send = fftreg1 & 0x0000FFFF; put_char_hex(msg2send); } lcd_line(XPAR_LCD_CONTROLLER_0_BASEADDR, 2); lcd_write(XPAR_LCD_CONTROLLER_0_BASEADDR, "Imag Spec dumped"); } fftreg0 = RDDIS & WRDIS & FFTIMAG & CAPSTOP & FFTSTOP; *(volatile unsigned long *)XPAR_FFTRTL_1024_0_BASEADDR = fftreg0; } return 0; }