However when I connected to my PC's serial port and ran minicom ... I still got back gibberish ... I have to consider that perhaps I left something out ... the PC's rs232 level converter is damaged ? or I should be driving the db9 ttl-to-rs232 adapter with 5v and not 3v?
One other small note:
start compiling with -O2 optimization!!!
/* *********************************************************************** *name: Samuel Igwe *date: 07/04/2015 *description: main ... what else * phase 1: system initialization * led + timer * phase 2: the above with * uart communication 115200 * simple monitor program * phase 3: the above with * fpga setup in order to control LED's * enabling static and dram memory controller * phase 4: the above with * usb host support in place for gamepads * /mouse/keyboards * phase 5: the above with * extended fpga support for usb controller * glue logic. *********************************************************************** */ #include "main.h" void test_determine_fractional_divider_values(void); int main(void) { volatile unsigned int wdTemp; const int wdGpio=18, wdTestVal='0'; asm ("ldr sp, =0x10010000"); setup_pll(); setup_nvic(); setup_gpio(); setup_gpdma(); setup_uart(); gpio_set_lpc_biled(0); while(1) { //wdTemp++; //uartio_printf("%d\r", wdTemp); // (LPC_GPIO1->SET) = (1 << wdGpio); //uartio_putc(wdTestVal); // (LPC_GPIO1->CLR) = (1 << wdGpio); test_determine_fractional_divider_values(); } } /* *********************************************************************** description: fractional divider test routine. used to tweak the uart baud rate clock notes: for this to work - put a paper clip between pin 2(rx) and pin 3(tx) of the serial cable. which effectively creates a loop back. then set a break point where the "if" test of the data read back evaluates as true *********************************************************************** */ void test_determine_fractional_divider_values(void) { volatile unsigned int wdTemp, wdCount, wdErrorFlag; volatile unsigned int wdMulVal, wdDivAddVal; const int wdGpio=18, wdTestVal='0'; /* ******************************************************************* cycle through the 14 x 15 fractional divider values reset RX fifo wait 1mS after setting fractional dividers write and read back three values in succession turn on flag if any error evaluate results ******************************************************************* */ for(wdMulVal = 1; wdMulVal <= 15; wdMulVal++) { for(wdDivAddVal = 0; wdDivAddVal <= 15; wdDivAddVal++) { wdTemp = (wdMulVal << 4); wdTemp |= wdDivAddVal; EGWU_ONBOARD_UART->FDR = wdTemp; timer_delay_mS(1); EGWU_ONBOARD_UART->FCR |= UART_FCR_RX_RS; for(wdCount = 0, wdErrorFlag = 0; wdCount < 3; wdCount++) { uartio_putc(wdTestVal + wdCount); if((uartio_getc()) != (wdTestVal + wdCount)) wdErrorFlag++; } if(wdErrorFlag == 0) { uartio_putc(wdMulVal); uartio_putc(wdDivAddVal); } } } /* ******************************************************************* flash bi-LED in a sequence every 500mS ******************************************************************* */ do { wdTemp++; gpio_set_lpc_biled(wdTemp); timer_delay_mS(500); }while(1); }
No comments:
Post a Comment