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
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
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.
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
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
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
Hi, Thanks for the response. I will implement this & get back to you if I have any questions
Thanks once again..