Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #39007
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | A Little Help Here? |
| Date | 2015-05-12 00:53 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <mis0te$p1v$1@dont-email.me> (permalink) |
I am reading a multiplexed, 3 digit, 7 segment LED display and
converting it to a number. I have the code working pretty well except
that maybe once in a couple of hundred reads it glitches. I would
believe I missed something in my code or that the hardware is not
perfect, but the symptoms don't point to anything I can pin down.
First I read the three bits that indicate which digit is being displayed
and when that is on a new digit the word exits returning the three bit
one-hot code (1, 2, 4) to indicate which bit. For some reason I see
this routine returning the same digit on two successive calls which it
is supposed to not do.
Perhaps someone else can spot something I am missing...
: newdigit@ ( c1 -- c2 ) \ sync to new digit
begin digits@ 2dup = over 0= or key? not and while
drop delay repeat nip ;
c1 is the last digit code read and c2 should be a different one. The
digits@ reads the port with the three bits, one-hot encoded. The loop
exits when either the code changes but not if it goes to zero or a key
is pressed. Here is the routine that calls this code.
: poll_loop ( -- ) \ read and display succesive digits from LED
LED_Init
0 begin
newdigit@ segments@ conv7segtodec digit. dup 4 =
if 13 emit cr then \ Mecrisp sends LF from CR word
key? until key drop ;
This word is just reading, repeatedly displaying the digits until it
gets the last one and starts a new line, nothing complex here.
The only way I can see to debug this problem is with a logic analyzer
which is going to be a PITA. Or I can just code around it. I know
which digit is returned from the 7 seg > decimal conversion, so if I get
the same one twice I can ignore it. I just hate having bugs I don't
understand. You never know if they might bite you later.
I am viewing this data on a raspberry Pi running e4thcom which is
connected to the target via a USB serial interface at 115200 bps. The
error always appears to be an isolated double read of different digits,
so I don't suspect the data path is dropping characters which would
produce more random stuff.
It is late and I guess I'm getting tried. I'll hit this again in the
AM. Sometimes I think by writing down the problem, but nothing came to
me this time other than the work around.
--
Rick
Back to comp.lang.forth | Previous | Next — Next in thread | Find similar | Unroll thread
A Little Help Here? rickman <gnuarm@gmail.com> - 2015-05-12 00:53 -0400
Re: A Little Help Here? rickman <gnuarm@gmail.com> - 2015-05-12 03:51 -0400
Re: A Little Help Here? rickman <gnuarm@gmail.com> - 2015-05-12 03:54 -0400
Re: A Little Help Here? "Rod Pemberton" <bork@lllljunkqwer.cpm> - 2015-05-12 04:09 -0400
Re: A Little Help Here? Tessa Bonting <tessa.bonting@gmail.com> - 2015-05-12 07:48 -0700
Re: A Little Help Here? rickman <gnuarm@gmail.com> - 2015-05-12 13:51 -0400
Re: A Little Help Here? "Alex McDonald" <blog@rivadpm.com> - 2015-05-12 19:46 +0100
Re: A Little Help Here? "Alex McDonald" <blog@rivadpm.com> - 2015-05-12 19:53 +0100
Re: A Little Help Here? rickman <gnuarm@gmail.com> - 2015-05-12 20:15 -0400
Re: A Little Help Here? "Elizabeth D. Rather" <erather@forth.com> - 2015-05-12 19:29 -1000
Re: A Little Help Here? rickman <gnuarm@gmail.com> - 2015-05-12 21:18 -0400
Re: A Little Help Here? all2001@spambog.com (Wolfgang Allinger) - 2015-05-12 08:37 -0300
Re: A Little Help Here? rickman <gnuarm@gmail.com> - 2015-05-12 20:18 -0400
Re: A Little Help Here? all2001@spambog.com (Wolfgang Allinger) - 2015-05-12 23:08 -0300
Re: A Little Help Here? rickman <gnuarm@gmail.com> - 2015-05-13 03:31 -0400
Re: A Little Help Here? all2001@spambog.com (Wolfgang Allinger) - 2015-05-13 07:32 -0300
Re: A Little Help Here? rickman <gnuarm@gmail.com> - 2015-05-13 16:47 -0400
Re: A Little Help Here? all2001@spambog.com (Wolfgang Allinger) - 2015-05-13 17:48 -0300
Re: A Little Help Here? rickman <gnuarm@gmail.com> - 2015-05-13 22:01 -0400
Re: A Little Help Here? Tessa Bonting <tessa.bonting@gmail.com> - 2015-05-13 08:56 -0700
Re: A Little Help Here? Tessa Bonting <tessa.bonting@gmail.com> - 2015-05-13 09:22 -0700
Re: A Little Help Here? rickman <gnuarm@gmail.com> - 2015-05-13 16:56 -0400
csiph-web