Altera_Forum
Honored Contributor
16 years agoGood progress on UART
I have my Uart Working, but not perfectly, GPGGA comes from the GPS chip once a second, about every 5 seconds my UART reads it perfeclty giving my Time and position, any sugestions how to fine tune this?
//working under 27mhz clock, Buad rate it 9600, 1 start bit, docs do not indicate stop bit if (bitcount!=0) bitlength=2812; if (bitcount==0) bitlength=3800; if (uartf==0 & GPSIN==0) begin uartf<=1; bitstreamin<=0; bitcount<=0; bitqueu<=bitqueu << 8; // shifting queu left 8 bits to make space for new byte end if (uartf==1) begin if (bittimer!=bitlength) bittimer<=bittimer+1; if (bittimer==bitlength) begin // bitstreamin[10]<=bitstreamin[9]; bitstreamin[9]<=bitstreamin[8]; bitstreamin[8]<=bitstreamin[7]; bitstreamin[7]<=bitstreamin[6]; bitstreamin[6]<=bitstreamin[5]; bitstreamin[5]<=bitstreamin[4]; bitstreamin[4]<=bitstreamin[3]; bitstreamin[3]<=bitstreamin[2]; bitstreamin[2]<=bitstreamin[1]; bitstreamin[1]<=bitstreamin[0]; bitstreamin[0]<=GPSIN; bittimer<=0; bitcount<=bitcount+1; end if (bitcount==9) begin uartf<=0; bitcount<=0; bitqueu[0]<=bitstreamin[8]; bitqueu[1]<=bitstreamin[7]; bitqueu[2]<=bitstreamin[6]; bitqueu[3]<=bitstreamin[5]; bitqueu[4]<=bitstreamin[4]; bitqueu[5]<=bitstreamin[3]; bitqueu[6]<=bitstreamin[2]; bitqueu[7]<=bitstreamin[1]; end end // gpsdecode(bitstreamin,charcount,latitude,longitude,gpstime) /// ascii "$"=24h "A"=41h "G"=47h "P"=50h "A"=41h // //$GPGGA asci hex = 244750474741 //$GPGGA,hhmmss.ss,llll.lll,a,nnnnn.nnn,b,t,uu, // Active low GPSIN (PDFLINK ABOVE FOR GPS MODULE) // LED TO PPS PIN SHOWS GPS properly powered // $GP ascii=2447h // hits to this per second if (bitqueu[447:400]==48'h244750474741) begin secsmain<=secsmain+1; gpstream<=bitqueu; bitqueu<=0; end mLEDR<=rledt; end //posedge clock27