M5329, interrupts

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

M5329, interrupts

1,613 Views
VeronicaFNX
Contributor I
Hello,
 
I want to have two interruptions:

1 .- the Uart
2 .- Programmable Timer
 
so I do in main.c
 

 mcf5xxx_irq_disable();
 uart_init(0, 60000, 19200, 0);
 init_uart_config();
 init_interrupt_timers();
// init_interrupt_controller(); //SE BLOQUEA EL EQUIPO!!

    // Pines del Timer como GPIO outputs
 MCF_GPIO_PDDR_TIMER = MCF_GPIO_PDDR_TIMER_PDDR_TIMER3 |
                          MCF_GPIO_PDDR_TIMER_PDDR_TIMER2 |
                          MCF_GPIO_PDDR_TIMER_PDDR_TIMER1 |
                          MCF_GPIO_PDDR_TIMER_PDDR_TIMER0;
    MCF_GPIO_PAR_TIMER = 0;
 
 
 mcf5xxx_set_handler (90, &Uart0_handler);   //habilita interrupcion de la Uart
 mcf5xxx_set_handler (171, &PIT0_handler); //habilita interrupcion PIT0
 mcf5xxx_irq_enable();      //Global interrupt enable
 
/*********************************************************************
* init_uart_config - Clock Module                                   *
**********************************************************************/
void init_uart_config (void)
{
 /* Configure UART 0 (first UART channel)
       Baud Rate = 19200
       8 data bits, 1 stop bit, No parity
       /CTS input has no effect on the transmitter
       /RTS output is not affected by receiver or transmitter
    */
    /* UART 0: Reset transmitter, receiver and mode register pointer */
    MCF_UART0_UCR = MCF_UART_UCR_MISC(0x3);
    MCF_UART0_UCR = MCF_UART_UCR_MISC(0x2);
    MCF_UART0_UCR = MCF_UART_UCR_MISC(0x1);
    /* UART 0 Mode Registers */
    MCF_UART0_UMR = MCF_UART_UMR_PM(0x2) |
                    MCF_UART_UMR_BC(0x3);
    MCF_UART0_UMR = MCF_UART_UMR_SB(0x7);
    /* UART 0 Clocking */
    MCF_UART0_UCSR = MCF_UART_UCSR_RCS(0xd) |
                     MCF_UART_UCSR_TCS(0xd);
    MCF_UART0_UBG1 = 0;
    MCF_UART0_UBG2 = 0x82;
    /* UART 0 Interrupt mask */
    MCF_UART0_UIMR = MCF_UART_UIMR_RXRDY_FU |
                     MCF_UART_UIMR_TXRDY; 
    /* UART 0 Miscellaneous */
    MCF_UART0_UACR = 0;
    /* UART 0: Enable receiver and transmitter */
    MCF_UART0_UCR = MCF_UART_UCR_TXC(0x1);
    MCF_UART0_UCR = MCF_UART_UCR_RXC(0x1);
   
    // Habilita la interrupcion de la Uart
//    MCF_INTC0_ICR26 = MCF_INTC_ICR_IL(0x06);
// MCF_INTC0_IMRH &= ~MCF_INTC_IMRL_INT_MASK26;
}

/*********************************************************************
* init_interrupt_timers - Programmable Interrupt Timers (PIT)        *
**********************************************************************/
void init_interrupt_timers (void)
{

 MCF_PIT0_PCSR = 0;
 MCF_PIT0_PCSR = MCF_PIT_PCSR_PRE(0x1) |
                    MCF_PIT_PCSR_PIE      |
                    MCF_PIT_PCSR_OVW      |     // Set overwrite flag
                    MCF_PIT_PCSR_RLD      |
                    MCF_PIT_PCSR_EN;
    MCF_PIT0_PMR = MCF_PIT_PMR_PM(0x9c3f);
    MCF_PIT1_PCSR = 0;  // PIT1 disabled (PCSR1[EN]=0)
    MCF_PIT2_PCSR = 0;  // PIT2 disabled (PCSR2[EN]=0)
    MCF_PIT3_PCSR = 0;  // PIT3 disabled (PCSR3[EN]=0)
}

/********************************************************************/
__declspec(interrupt:0)
void PIT0_handler (void)
{
uint32 i;
 MCF_PIT0_PMR |= MCF_PIT_PCSR_PIF;
 MCF_GPIO_PODR_TIMER &= ~MCF_GPIO_PODR_TIMER_PODR_TIMER3;// apaga los leds
 for (i=0; i<0xFFF; i++);
    MCF_GPIO_PODR_TIMER |= MCF_GPIO_PODR_TIMER_PODR_TIMER3; // enciende los leds
    for (i=0; i<0xFFF; i++);
 
}

/********************************************************************/
__declspec(interrupt:0)
void Uart0_handler (void)
{
 if ( (MCF_UART0_UISR & MCF_UART_UISR_RXRDY_FU) == MCF_UART_UISR_RXRDY_FU )
 {
  uart_putchar (0, (char)0x67);
  printf("R");
 }
 if ( (MCF_UART0_UISR & MCF_UART_UISR_TXRDY) == MCF_UART_UISR_TXRDY )
 {
  uart_putchar (0, (char)0x68);
  printf("T");
 }
}
But I did not get anything.
Does anyone know tell me what the problem is?
 
Thanks,
 Veronica
Labels (1)
0 Kudos
Reply
2 Replies

609 Views
wstrong
Contributor I
The mcf5xxx_set_handler() routine only loads the exception vector table. ( __VECTOR_RAM[vector] = (uint32)handler;  ).

I didn't see where in your code, but you need to turn on the interrupt and set its priority.  e.g.
            MCF_INTC0_CIMR = 35;                        // DTIM3
            MCF_INTC0_ICR35 =  MCF_INTC_ICR_IL(3);      // Interrupt Level (0..7)
            MCF_INTC1_CIMR = 43;                        // PIT1
            MCF_INTC1_ICR43 =  MCF_INTC_ICR_IL(3);      // Interrupt Level
            // Uart stuff too.
     
Regards,
Wayne


0 Kudos
Reply

609 Views
VeronicaFNX
Contributor I
Thanks,
 
it was the problem. Now I have interrupts.
 
Veronica
0 Kudos
Reply