Re: Can anyone tell me where the bug is???

Eric McRae <[email protected]>
Newsgroups gmane.comp.hardware.motorola.microcontrollers
Message-ID <[email protected]>
Hi Sasanka,

Based on your symptoms (stuck after first interrupt), I'm guessing that 
you're not clearing the transmit interrupt from the TPU.  I see code 
that clears the receive interrupt but you're going to get the transmit 
interrupt first and if you don't clear it, you'll spin in interrupt hell 
forever!

G.V.Sasanka wrote:

> Hi,
>     I am trying to work on a simple program which is an extension of 
> tpu uart function( A2371) with interrupts, I am using Phytec MPC555 
> core and codewerks metrowarrior compiler...can someone tell me where 
> the bug is...my program is getting stuck as soon as I interrupt is 
> risen..I feel...I shall ne happy if someone can clarify me whether my 
> interrpt intialization is correct...here is my program
> regards,
> Sasanka.G.V
>
> #include "mpc555.h"
> #include "mpc500_util.h"
> #include "tpu_uart.h"
> #include "UART.H"
> #define UART_BAUD_RATE 0x01b2 /* set the baud rate, ~9600 baud */
> #define UART_DATA_SIZE 0x0008 /* set data size of transmit and receive 
> data*/
> #define TICR (* (volatile unsigned short *) 0x00304008)
>
> #ifdef __cplusplus
> extern "C" {
> #endif
> void InterruptHandler(long cause);
> #ifdef __cplusplus
> }
> #endif
> #define DISABLE  asm{ mtspr EID, r0 } // Set MSR.EE
> #define ENABLE   asm{ mtspr EIE, r0 } // Clear MSR.EE
>
> struct TPU3_tag *tpua = &TPU_A;
> void main()
> {
> /* pointer for TPU routines */
> UINT8 parity_error; /* parity error flag */
> UINT8 framing_error; /* framing error flag */
> INT16 receive_data; /* received data */
> char test_message[] = "1 2 3 4 5 6 7 8 9 This is a test of the TPU 
> transmitter function";
> char store_receive_data_pointer[100]; /* place to store received data */
> int i; /* index variable */
> TICR=0x0e00;
> DISABLE
> InitPort1();                          /* set handle for the first UART */
> InitializeUART(kBaud9600);
> InitializeLED();
> SwitchGreenLEDOn();
> printf("\r\nHello \r\n");
> /* initialize channel 0 to act as a transmitter */
> tpu_uart_transmit_init(tpua, 0, TPU_PRIORITY_HIGH, UART_BAUD_RATE, 
> UART_DATA_SIZE, \
> TPU_UART_NOPARITY, TPU_UART_INTERRUPT);
> /* initialize channel 1 to act as a receiver */
> tpu_uart_receive_init(tpua, 1, TPU_PRIORITY_HIGH, UART_BAUD_RATE, 
> UART_DATA_SIZE, \
> TPU_UART_NOPARITY, TPU_UART_INTERRUPT);
> ENABLE for(i=0; test_message[i] != '\0'; i++)
> {
> tpu_uart_write_transmit_data(tpua, 0, test_message[i]); /* send data to be
> transmitted */
> SwitchGreenLEDOff();
> while((tpu_check_interrupt(tpua, 0)) != 1) /* wait for data to be 
> transmitted*/
>
> while((tpu_check_interrupt(tpua, 1)) != 1)/* check for received data 
> available */
> {
> }
> /* read received data, check for parity and framing error */
> tpu_uart_read_receive_data(tpua, 1, &receive_data, &parity_error, 
> &framing_error);
> tpu_clear_interrupt(tpua, 1); /* clear receive interrupt status 
> channel 1*/
> /* save received data read in memory, mask to eight bit data */
> store_receive_data_pointer[i] = receive_data;
> }
> store_receive_data_pointer[i] = '\0';
> printf("the stored message is \n \r");
> for(i=0; store_receive_data_pointer[i] != '\0'; i++)
> {
> printf("%c",store_receive_data_pointer[i]);
> }
> }
>
> void InterruptHandler(long cause)
> {
> static unsigned int count=100;
> switch(cause)
> {
>   case 0x500:
>    SwitchRedLEDOn();
>    if(tpu_check_interrupt(tpua, 0) == 1)
>    {
>     SwitchGreenLEDOn();
>    }
> }
> }
>
>
>
>
>
> Send instant messages to your online friends 
> http://uk.messenger.yahoo.com
>
> [Non-text portions of this message have been removed]
>
>
>
> -----------------------------------------------------------
> To learn more about Freescale Microcontrollers, please visit
> http://www.freescale.com/mcu
>
>
>
>
>
>
> SPONSORED LINKS
> Intel microprocessors 
> <http://groups.yahoo.com/gads?t=ms&k=Intel+microprocessors&w1=Intel+microprocessors&w2=Pic+microcontrollers&w3=8085+microprocessor&c=3&s=78&.sig=B_gglo6oPjfvny4MR50mJg> 
> 	Pic microcontrollers 
> <http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Intel+microprocessors&w2=Pic+microcontrollers&w3=8085+microprocessor&c=3&s=78&.sig=xUhmC5G81SCtcJV6x7qsWg> 
> 	8085 microprocessor 
> <http://groups.yahoo.com/gads?t=ms&k=8085+microprocessor&w1=Intel+microprocessors&w2=Pic+microcontrollers&w3=8085+microprocessor&c=3&s=78&.sig=4tuA5VR_gFWoruiF9v6hVg> 
>
>
>
> ------------------------------------------------------------------------
> YAHOO! GROUPS LINKS
>
>     *  Visit your group "MPC500
>       <http://groups.yahoo.com/group/MPC500>" on the web.
>        
>     *  To unsubscribe from this group, send an email to:
>        [email protected]
>       <mailto:[email protected]?subject=Unsubscribe>
>        
>     *  Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>       Service <http://docs.yahoo.com/info/terms/>.
>
>
> ------------------------------------------------------------------------
>

-- 
Eric McRae, Electro-Logic Machines, Inc.
511 Root St., Port Townsend WA, 98368
Phone/Fax: 360.379.0969, http://www.elmi.com



------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a href="http://us.ard.yahoo.com/SIG=12h304r9l/M=362131.6882499.7825260.1510227/D=groups/S=1706554205:TM/Y=YAHOO/EXP=1124132784/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
">Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life - brought to you by One Economy</a>.</font>
--------------------------------------------------------------------~-> 

-----------------------------------------------------------
To learn more about Freescale Microcontrollers, please visit
http://www.freescale.com/mcu


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/MPC500/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.