Can anyone tell me where the bug is???
"G.V.Sasanka" <[email protected]>
| Newsgroups | gmane.comp.hardware.motorola.microcontrollers |
|---|---|
| Message-ID | <[email protected]> |
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]
------------------------ Yahoo! Groups Sponsor --------------------~-->
<font face=arial size=-1><a href="http://us.ard.yahoo.com/SIG=12ho7n0hp/M=362335.6886445.7839731.1510227/D=groups/S=1706554205:TM/Y=YAHOO/EXP=1124131883/A=2894361/R=0/SIG=13jmebhbo/*http://www.networkforgood.org/topics/education/digitaldivide/?source=YAHOO&cmpgn=GRP&RTP=http://groups.yahoo.com/">In low income neighborhoods, 84% do not own computers. At Network for Good, help bridge the Digital Divide!</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/