2010-04-27 05:41:55     Bare metal - Core timer problem

Document created by Aaronwu Employee on Sep 26, 2013
Version 1Show Document
  • View in full screen mode

2010-04-27 05:41:55     Bare metal - Core timer problem

Morten Winkler (DENMARK)

Message: 88957   

 

Hi All.

 

Programming the BF561 bare metal, I have a problem enabeling the core timer.

I know for sure that delay and I/O routines are working. The main loop is executed just fine but doDA2 is never called.

I have tried to enable the core timer in routine setupTimer() but the registered doDA2() routine is never called.

 

Can anyone spot the error?

 

#include <cdefBF561.h>                                                                                                  

 

#include "../../lib/pins.h"

#include "../../lib/system.h"

 

 

void doDA2() {

  static char on = 0;

  if(on == 1) on = 0;

  else on = 1;

  switchDA2(on);

  asm("rti;");

}

 

 

void doDA1() {

  static char on = 0;

  if(on == 1) on = 0;

  else on = 1;

  switchDA1(on);

}

 

 

void setupTimer()

{

 

/* Pagenumbers are references to the hardware reference manual for the BF561. */

 

 

 

   *pEVT6 = doDA2;

 

   *pTPERIOD = 10000;

   *pTSCALE = 2;

   *pTCNTL  = 0x0001; //First enable power! p. 689  

   *pIMASK = 0x0040;    //Enable Core interrupt Mask Register (p 191)

   *pTCNTL  = 0x0007; //Then enable interrupt (and power again...) pp. 687

}

 

 

int main(void)

{

 

  *pFIO0_DIR = 0 | PIN7 | PIN1 | PIN9;

  *pFIO1_DIR = 0 | PIN18;

  *pFIO2_DIR = 0 | PIN44 | PIN46;

  switchDA2(1);

  setupTimer();

 

  while (1) {

     doDA1();

     delay(2000);

  }  

  return 0;

}

 

 

 

 

Best and thanks in advance.

 

Morten

QuoteReplyEditDelete

 

 

2010-04-27 05:54:30     Re: Bare metal - Core timer problem

Mike Frysinger (UNITED STATES)

Message: 88958   

 

you didnt say how you initialized the part.  you need to be at a lower IVG than the core timer, and you need to not have interrupts globally masked.

 

i.e. read ILAT and IPEND and make sure IPEND[4] isnt set

Attachments

    Outcomes