rising edge detection

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

rising edge detection

2,399件の閲覧回数
Jeremius
Contributor I

Hi,

 

i'm working on a project with the MCF52259 demokit board. We have to implement a sonic waves sensor.

A command is sent to the sensor (trigger pulse 50us) and the sensor answers with an echo pulse from 100us to 50ms (depends on the detected distance). The microcontroler has to count the pulse width.

 

The problem I have is the microcontroler doesn't detect the rising edge on the output sensor (the pin used is the first pin of the TC GPIO port). I supppose the gpio is bad configured but i dont know where is the problem.

 

I notice the MCF_GPIO_PORTTC port is connected to the leds and used to display them but I dont think that could be the problem.

 

regards,

 

jérémie

ラベル(1)
0 件の賞賛
返信
5 返答(返信)

1,559件の閲覧回数
scifi
Senior Contributor I

I'm assuming you are using a DMA timer in capture mode. You should configure the corresponding port to assume it's 'primary function' using the PTCPAR register.

For easy peripheral configuration, use the CFInit tool:

CFInit ColdFire Initialization Tool

0 件の賞賛
返信

1,559件の閲覧回数
Jeremius
Contributor I

CFinit works with MCF5225x family ??

 

 

Yes I use DMA timer 0 capture on rising edge, but i dont think i can use any ports (for the capture)

 

regards

0 件の賞賛
返信

1,559件の閲覧回数
scifi
Senior Contributor I

 


Jeremius wrote:

CFinit works with MCF5225x family ??

 


The MCF5225x shares many peripherals with the MCF5223x and others. That makes it possible to use CFInit with the MCF5225x.

 

0 件の賞賛
返信

1,559件の閲覧回数
Jeremius
Contributor I

Hi,

 

CFInit is really nice but i still have problems for my project.

 

GPIO 1 is an output, I send a trigger pulse (1OOus) to enable the sensor.

DTIN0 is an input, i receive a pulse from the sensor and i want to to count the pulse width.

I used DMA Timer 0 in interrupt mode (i didnt choose capture mode) on either rising and falling edges.

 

rising edge and falling edge seem to work but the counter values are always the same

 

 

the code is really simply, that s why i posted it

voidleds_init(void){    /* Enable signals as GPIO */    MCF_GPIO_PTCPAR = 0        | MCF_GPIO_PTCPAR_DTIN3_GPIO        | MCF_GPIO_PTCPAR_DTIN2_GPIO        | MCF_GPIO_PTCPAR_DTIN1_GPIO        | MCF_GPIO_PTCPAR_DTIN0_DTIN0; //dtin0 is an input        /* Enable signals as digital outputs */    MCF_GPIO_DDRTC = 0        | MCF_GPIO_DDRTC_DDRTC3        | MCF_GPIO_DDRTC_DDRTC2        | MCF_GPIO_DDRTC_DDRTC1; MCF_GPIO_PORTTC = 0x00; // TURN LEDS OFF}voidboard_led_display(uint8 number){    /* Set output values */    MCF_GPIO_PORTTC = number;}__interrupt__ voiddtim0_handler(void){static int rise_fall = 0; if (rise_fall == 0) {  COUNT_R = MCF_DTIM0_DTCN;  MCF_DTIM0_DTCN = 0;  rise_fall = 1; } else {  COUNT_F = MCF_DTIM0_DTCN; }    /* Clear the interrupt event */    MCF_DTIM0_DTER |= MCF_DTIM_DTER_REF;}void main (void){    MCF_INTC0_ICR19 = MCF_INTC_ICR_IL(7) | MCF_INTC_ICR_IP(7);    MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_INT_MASK19 | MCF_INTC_IMRL_MASKALL);    /* Set the interrupt handlers in the vector table */    mcf5xxx_set_handler(64 + 19, (ADDRESS)dtim0_handler);  /* Initialize the LED's */ leds_init();     /* Global interrupt enable */ mcf5xxx_irq_enable();    /* Configure DTIM0 as a timeout counter */    MCF_DTIM0_DTCN = 0;    MCF_DTIM0_DTXMR = 0;    MCF_DTIM0_DTRR = MCF_DTIM_DTRR_REF(0xffffffff); //MCF_DTIM0_DTRR  = (DELAY - 1);    MCF_DTIM0_DTMR  = 0     | MCF_DTIM_DTMR_CE(0x3)        | MCF_DTIM_DTMR_PS(SYS_CLK_MHZ)        | MCF_DTIM_DTMR_FRR        | MCF_DTIM_DTMR_CLK_DIV1        | MCF_DTIM_DTMR_RST;    while (1)      {        /* Send trigger pulse on GPIO 1 */        board_led_display(2);        delay(1000);        board_led_display(0);        delay(10000000); //wait input signal (    }}

 

Regards,

Jérémie

0 件の賞賛
返信

1,559件の閲覧回数
Jeremius
Contributor I

Hi,

 

great I fixed my problems :smileyhappy:

 

currently the DTMA timer didnt want to be re-initilialized to zero but i can manage it without

didnt understand why MCF_DTIM0_DTCN = 0; does not work

 

regards,

0 件の賞賛
返信