I fixed it.

BLUF:  At the top of my timer1 code, I inserted "decimal".

I back tracked my code and found out that if I didn't load bitnames.frt, my
timer1 code would behave correctly.  I noticed that bitnames.frt had a
"hex" declaration at the top.  It led me to think that that declaration
persisted until my timer1 code was loaded.  Thus the "decimal" declaration
was inserted.

I don't know if it is poor coding practice to not declare a base at the
beginning of the file, but I'll adopt that practice.

It is interesting to note that I explicitly declare my number bases in my
words. i.e. $ for hex % for binary.  So I don't see how the lack of decimal
declaration affects the performance of my interrupt code.

This is my code:

decimal
variable timer1.interrupt

: timer1.isr
  1 timer1.interrupt ! \ signal that the timer has triggered
;

\ initialization setting for timer1 interrupt
: timer1.init ( -- )
  $ffff OCR1A !
  0 timer1.interrupt !
  ['] timer1.isr TIMER1_COMPAAddr int!
  ;

: timer1.start
  0 timer1.interrupt !
  %00001100 TCCR1B c! \ no input capture, ctc mode 4, prescaler to 256
  %00000010 TIMSK1 c! \ timer 1 output compare A match interrupt enable
  ;

: timer1.stop
  %00000000 TCCR1B c! \ no input capture, ctc mode 4, prescaler to 256
  %00000000 TIMSK1 c! \ stop int1
  ;

: testtimer1
  begin
  timer1.interrupt @ 1 = if ." T " CR 0 timer1.interrupt ! then
  key? until ;

Thanks.
Keith


On Fri, Apr 4, 2014 at 5:33 AM, <amforth-devel-requ...@lists.sourceforge.net
> wrote:

> Send Amforth-devel mailing list submissions to
>         amforth-devel@lists.sourceforge.net
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://lists.sourceforge.net/lists/listinfo/amforth-devel
> or, via email, send a message with subject or body 'help' to
>         amforth-devel-requ...@lists.sourceforge.net
>
> You can reach the person managing the list at
>         amforth-devel-ow...@lists.sourceforge.net
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Amforth-devel digest..."
>
>
> Today's Topics:
>
>    1. Re: Amforth-devel Digest, Vol 66, Issue 11 (Keith Weisz)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 3 Apr 2014 06:03:39 -0700
> From: Keith Weisz <kern...@gmail.com>
> Subject: Re: [Amforth] Amforth-devel Digest, Vol 66, Issue 11
> To: amforth-devel@lists.sourceforge.net
> Message-ID:
>         <
> cajdosn6xer6f4zvt5r-hnphye2bhha5ppzn-tn5fvc2edyk...@mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Matthias,
> Just a quick update.
> I downloaded amforth-5.2 again and started from scratch.  I can now get
> timer1.frt to work with a fresh load of amforth via avrdude.  However, when
> I load my code first and then my timer1 code, it goes into an continuous
> reboot after starting timer1.  It is as if the ISR vector is being set to
> 0x00.
>
> I'll start doing a manual load of my code file by file and see if I can
> identify the offending file.
>
> Thanks much.
> Keith
>
>
> On Sun, Mar 30, 2014 at 5:02 AM, <
> amforth-devel-requ...@lists.sourceforge.net> wrote:
>
> > Send Amforth-devel mailing list submissions to
> >         amforth-devel@lists.sourceforge.net
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> >         https://lists.sourceforge.net/lists/listinfo/amforth-devel
> > or, via email, send a message with subject or body 'help' to
> >         amforth-devel-requ...@lists.sourceforge.net
> >
> > You can reach the person managing the list at
> >         amforth-devel-ow...@lists.sourceforge.net
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of Amforth-devel digest..."
> >
> >
> > Today's Topics:
> >
> >    1. Re: Timer1 on Atmega328p (Matthias Trute)
> >
> >
> > ----------------------------------------------------------------------
> >
> > Message: 1
> > Date: Sat, 29 Mar 2014 20:24:50 +0100
> > From: Matthias Trute <mtr...@web.de>
> > Subject: Re: [Amforth] Timer1 on Atmega328p
> > To: Everything around amforth <amforth-devel@lists.sourceforge.net>
> > Message-ID: <1396121090.2342.2.camel@Ayla>
> > Content-Type: text/plain; charset="utf-8"
> >
> > Hi Keith,
> >
> > > I'm trying to set up timer1 on my Arduino Duemilanove board.  I can
> > > successfully load the timer1.frt file in arduino-5.2/lib/hardware.
> >  After a
> > > fresh restart I execute:
> > >
> > > 4096 timer1.init
> > >
> > > and then
> > >
> > > timer1.start
> > >
> > > It responds with
> > >   ok
> > > >
> > >
> > > and then stops responding.
> >
> > I get the following
> >
> > (ATmega328P)> timer1.tick @ .
> > -31994  ok
> > (ATmega328P)> 4096 timer1.init
> >  ok
> > (ATmega328P)>
> > (ATmega328P)> timer1.tick @ .
> > 0  ok
> > (ATmega328P)> timer1.start
> >  ok
> > (ATmega328P)> timer1.tick @ .
> > 32  ok
> > (ATmega328P)> timer1.tick @ .
> > 53  ok
> > (ATmega328P)> timer1.tick @ .
> > 73  ok
> > (ATmega328P)> timer1.tick @ .
> >
> > It works for me.
> >
> > Matthias
> >
> > ------------------------------
> >
> >
> >
> ------------------------------------------------------------------------------
> >
> >
> > ------------------------------
> >
> > _______________________________________________
> > Amforth-devel mailing list
> > Amforth-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/amforth-devel
> >
> >
> > End of Amforth-devel Digest, Vol 66, Issue 11
> > *********************************************
> >
>
>
> ------------------------------
>
>
> ------------------------------------------------------------------------------
>
>
> ------------------------------
>
> _______________________________________________
> Amforth-devel mailing list
> Amforth-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/amforth-devel
>
>
> End of Amforth-devel Digest, Vol 67, Issue 1
> ********************************************
>
------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to