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