MCF52233: General Purpose Timer [GPT]

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCF52233: General Purpose Timer [GPT]

3,316 Views
Lakshmi
Contributor II

Hi,

 

We are using MCF52233 processor. We want to implement GPT.

 

We have used all the 3 DMA timers, QSPI, UART, EPORT for other functionality.

 

We have switch buttons interfaced to MCF52233 processor board. These 4 switches are configured to IRQ8 to IRQ15. Two IRQ pins dedicated for each button.

 

Now we are implementing debounce timer concept here. I checked the sampl code provided by freescale for GPT, but did not get clarity about how to do the register settings.

 

Please Note: These GPT pins (GPT0-GPT3) are grounded in the hardware. Is it possible for us to use these pins for the purpose of running the timer for about 10ms?

 

Could anyone please help me with the register settings or any sample code??

 

Thanks in Advance

Labels (1)
0 Kudos
9 Replies

693 Views
Radek21
Contributor I

Hi, 

I have no experience with this MCU. I worked on MCF5234 but I guesse it would be pretty similar.

 

Here is part of my code to setup DMA timer 0:

 

__interrupt__ void DTIM0_isr(void)
{
  MCF_TIMER_DTER0 = MCF_TIMER_DTER_REF;
}

void timerSetup() 
{
  // Setup DMA timer 0 interrupt
  MCF_INTC0_ICR19 = MCF_INTC_ICR_IL(0x06) | MCF_INTC_ICR_IP(0);
  MCF_INTC0_IMRL &= ~MCF_INTC_IMRL_INT_MASK19;
  VECTOR_TABLE[0x53] = (int)DTIM0_isr;
  // Enable the DMA Timer 0
  MCF_TIMER_DTRR0 = 1023;
  MCF_TIMER_DTER0 = MCF_TIMER_DTER_REF;
  MCF_TIMER_DTMR0 = MCF_TIMER_DTMR_PS(8)
  | MCF_TIMER_DTMR_ORRI
  | MCF_TIMER_DTMR_FRR
  | MCF_TIMER_DTMR_CLK_DIV1
  | MCF_TIMER_DTMR_RST;

  // unmask all interrupts
  MCF_INTC_IMRL &= ~MCF_INTC_IMRL_MASKALL; 
 }

 

 

 Don't forget to start global interrupt level with:  asm volatile ("move.w #2000, %sr");

 

 

Good luck 

Radek

0 Kudos

693 Views
Lakshmi
Contributor II

Hi,

 

Thank you so much for the response, but this does not answer my question.

 

My question was:

 

 I want to use GPT for generating 10ms timer. But these pins, GPT0-GPT3 are grounded in the hardware. Is it possible for me to utilize these pins to generate 10ms timer??? (I do not want to use Pulse Accumulator feature of this)

 

If it is possible, then please provide me with the sample code, for initialising the registers.

 

I cannot use DMA timer coz all the 3 DMA timers are utilised for other purpose.

0 Kudos

693 Views
Lakshmi
Contributor II
Or do I have any other option, other than GPT????
0 Kudos

693 Views
mjbcswitzerland
Specialist V

Hi

 

The M52233 has 4 DMA timers - do you still have one free (you say you are only using three of them (?)).

 

Also you didn't mention the PITs (Periodic Interrupt Timers). If these are still free they are easy to use for generating time delays.

 

Otherwise the question is a bit confusing. You write that the GPT pins are grounded and then ask whether they can be used. Are you planning on changing the HW so that they are not grounded?

 

Regards

 

Mark

 

0 Kudos

693 Views
Lakshmi
Contributor II
Hi Mark, Thanks so mush for the response. Yes the GPT pins are grounded in our hardware & we are not planning to alter the hardware as of now. So I need to manage with other peripherals. So according to you, PIT is more simple & appropriate to use, rather than GPT? I will briefly explain about what I am trying to implement. 1. We have a membrane switch connected to our customized freescale processor board. 2. There are totally 4 switches. Each switch is configured to a pair of IRQ pins [IR8 to IRQ15] 3. Due to the debounce factor, when the switch is pressed, inconsistently interrupt gets generated [Sometimes 2 or 3 or 5… just randomly] 4. So we decided to set 10ms timer for the key press & release. 5. For this purpose we decided to use GPT. But we aren’t sure if this could be used coz these pins are grounded in the hardware. 6. if you suggest PIT is a better option compared to GPT, can you please provide me with the sample code or register settings, if it is available with you? It would be of a great help for us. Thanks in advance
0 Kudos

693 Views
Lakshmi
Contributor II
Hi Mark,

Thanks so mush for the response.

Yes the GPT pins are grounded in our hardware & we are not planning to alter the hardware as of now.

So I need to manage with other peripherals. So according to you, PIT is more simple & appropriate to use, rather than GPT?

I will briefly explain about what I am trying to implement.

1.    We have a membrane switch connected to our customized freescale processor board.
2.    There are totally 4 switches. Each switch is configured to a pair of IRQ pins [IR8 to IRQ15]
3.    Due to the debounce factor, when the switch is pressed, inconsistently interrupt gets generated [Sometimes 2 or 3 or 5… just randomly]
4.    So we decided to set 10ms timer for the key press & release.
5.    For this purpose we decided to use GPT. But we aren’t sure if this could be used coz these pins are grounded in the hardware.
6.    if you suggest PIT is a better option compared to GPT, can you please provide me with the sample code or register settings, if it is available with you? It would be of a great help for us.

Thanks in advance

0 Kudos

693 Views
Radek21
Contributor I

 

Here is code for MCF5485 to setup the GPTtimer:

 

#define TIMER           0 

#define DELAY_TIME   10000   // in uS

 

 

  MCF_GPT_GMS( TIMER ) = MCF_GPT_GMS_IEN | MCF_GPT_GMS_TMS_GPIO;
  MCF_GPT_GCIR( TIMER ) = MCF_GPT_GCIR_PRE(100) | MCF_GPT_GCIR_CNT( DELAY_TIME );
  MCF_GPT_GMS( TIMER ) |= MCF_GPT_GMS_CE;
 

Be sure that CE bit is modiefied last.

 

If you still have one free GPT timer, please use it for handling all of switches. For example: make a simple shared timer. 

 

 

 Grounded GPT pins should not have influence to behaviour of GPT timer if you haven't enabled alternate functionality.

 

 

 

Radek
0 Kudos

693 Views
mjbcswitzerland
Specialist V

Hi

 

Since the GPTs are based on a single 16 bit counter (shared between channels) it is generally not as flexible as other available timers. The PIT (there are 2 in your chip) are very easy to use to generate time delays and periodic interrupts.

 

Generally I wouldn't usually use edge interrupts with mechanical switches due to the debounce problems. Usually it is easier to poll them (based on a single timer) at say 50ms since this automatically has a debouncing effect.

 

There are references to the use of the different timer types and also a discussion of debouncing the Edge port interrupts here:

http://www.utasker.com/forum/index.php?topic=393.0

http://www.utasker.com/forum/index.php?topic=438.0

http://www.utasker.com/forum/index.php?topic=383.msg1563#msg1563

 

Regards

 

Mark

 

www.uTasker.com

 

 

0 Kudos

693 Views
Lakshmi
Contributor II

 Hi, Thanks for the response. I will implement this & get back to you if I have any questions

 

Thanks once again..

0 Kudos