This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

SH4 (7760) Timer Initializataion


I'm working on a eCos port for the SH7760 processor running on a Logic
Development Card Engine and I need some advice.

I've created a template for the 7760 for configtool and used that to
build redboot.  Then I was able to successfully start reboot on the card
engine.

So far so good.

Next I tried to create a sample application (basic1.c from the 'Embedded
Software Development with eCos' book) using a eCos kernel built from my
template.  That also built fine.

Here's were things went wrong.

When I loaded it on the card engine it hung.  After a bit a tracing with
an ICE, I was able to see that the processor was stuck in
cyg_hal_plf_scif_set_baud() in sh4_scif.c.

The serial ports works fine in redboot and after a bit of digging I
found why.  In hal_if.c, delay_us() is implemented differently
CYGPKG_KERNEL is defined. 

When I compile redboot (CYGPKG_KERNEL not defined), delay_us() will call
HAL_DELAY_US(), which works correctly.  When I build an application with
a (CYGPKG_KERNEL defined), then delay_us() calls the macro
HAL_CLOCK_READ() to wait for the proper time to elapse.  The problem is
that when HAL_CLOCK_READ() is called, the timer hasn't been initialized
yet and isn't counting.  This creates an infinite loop at that point.  

The initialization code for the timer is defined in clock.cxx in the
constructor for Cyg_RealTimeClock, which I believe will be called
(eventually) from vectors.S in complete_setup() but I'm still in the
platform initialization portion of complete_setup() when I hang.

What I need is some advice on how to resolve this in a proper manner.  I
can see a couple of solutions, but I don't know the eCos development
methodology well enough to pick one:

1) I could be doing something basicly wrong in my template I've created
which is causing my problems.

2) In my template hal_diag.c platform call cyg_hal_plf_comms_init(), I
could start the timer used by the kernel counting without interrupts.

3) In hal_if.c, I could modify delay_us to initialize the timer if it
hasn't been done yet.

4) ???

I think that #2 is the correct option, but I'd like some other opinions
on that.

thanks,
Jeff Cooper
-- 
Jeff Cooper
Senior Embedded Software Engineer

jeffc@logicpd.com    Logic Product Development
612-436-5176         411 N. Washington Ave. Suite 101
                     Minneapolis, MN  55401


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]