Author Topic: PIT from fnInitHW  (Read 8449 times)

Offline svl

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
PIT from fnInitHW
« on: October 08, 2009, 09:29:52 AM »
Hi Mark

I am trying to port some code from a M52235 to M52255 and in this progress upgrading to the new Tuasker version 1,4.

My problem are that when I init the PIT from the fnInitHW function it is not fired until i exit the function even when i make a while{1} in the fnInitHW.

I init the PIT like this:
    pit_setup.int_type = PIT_INTERRUPT;
    pit_setup.int_handler = disk_timerproc;
    pit_setup.int_priority = PIT1_INTERRUPT_PRIORITY;
    pit_setup.count_delay = PIT_US_DELAY(10000);           // 10ms delay
    pit_setup.mode = PIT_PERIODIC;                                // repeat interrupt
    fnConfigureInterrupt((void *)&pit_setup);                     // enter interrupt for PIT1 test


Do you have any suggestion on how to get the PIT interupting the fnInitHW and thereby getting a time within the function?

Regards Steen

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: PIT from fnInitHW
« Reply #1 on: October 08, 2009, 04:08:59 PM »
Hi Steen

The problem that you have is that the interrupts have not been enabled (mask is still set to 7) while the code is running in the routine.
Interrupts are not enabled until the first task is scheduled.

However I see no problem in enabling interrupts within fnInitHW() by calling

#ifndef _WINDOWS
        asm_int_on();
#endif


If possible, I would suggest putting this just before the call to fnUserHWInit().
Also you could put your code in fnUserHWInit() since this is user code which can be executed very early on after a reset (but note that no heap is available yet).

Regards

Mark

P.S. As long as you don't discover problems like this I will add this to the development version since it may generally be useful to have interrupts enabled before fnUserHWInit()  is called.




Offline svl

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Re: PIT from fnInitHW
« Reply #2 on: October 12, 2009, 02:58:29 PM »
Hi Mark

Thanks for your reply.

It works perfect now;-)

Regards Steen