CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

UART RX interrupt problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
naughty_mark



Joined: 29 Aug 2012
Posts: 97

View user's profile Send private message

UART RX interrupt problem
PostPosted: Mon Sep 03, 2012 1:05 am     Reply with quote

Hi, there

I come back again with a new problem Embarassed

I declared a RS232 port and declared a receive interrupt for it. However, once I sent character to micro, it will jump into the default interruption code, which means the code can not find the UART1 RX interruption I defined!

I attach my code below
Code:

#if defined(__PCD__)
#include <33EP256MU814.h>
//#include <i2c.h>
#fuses HS,PR,NOWDT,ICSP2
//CKSFSM -enable oscillator clock switching mode when a OSC failure has occurred.
//#build (stack=256)
//#build (stack=0x1E00:0x1FFF)
#device ADC=12
#use delay(clock=20000000) // Actual crystal is 20M
#pin_select U1TX = PIN_D0
#pin_select U1RX = PIN_D1
#pin_select U2TX = PIN_D2
#pin_select U2RX = PIN_D3

#use RS232(UART1, /*STREAM = GSM, */BAUD=9600, /*XMIT = PIN_D0 , RCV = PIN_D1 ,  */BITS = 8, STOP = 1, PARITY = N, ERRORS) // Actual Baud is 38400 due to clock (10M not 20M)

//#use RS232(UART2, STREAM = MODBUS, BAUD=9600, XMIT = PIN_D2 , RCV = PIN_D3 ,  BITS = 8, STOP = 1, PARITY = N, ERRORS) // Actual Baud is 38400 due to clock (10M not 20M)

//#use spi(MASTER, DO = PIN_G8, CLK = PIN_G6, mode = 3, stream=SPI_STREAM)
#use i2c(MASTER, I2C1,SCL = PIN_D10, SDA = PIN_D9 , FORCE_SW)
#pin_select IC1=PIN_F0
#pin_select C1TX = PIN_D6
#pin_select C1RX = PIN_D5
#endif

and for UART1 RX interrupt
Code:

#INT_RDA
void RDA_isr()        // BYTE RECEIVED
{
   char tmp;
   output_low(PIN_J10);
   tmp = getc();
   recv[next_RS232_in] = tmp;
   next_RS232_in ++;
   testDone = TRUE;
   clear_interrupt(INT_RDA);
}

In my main function, I code
Code:
   clear_interrupt(INT_RDA);
   enable_interrupts(INT_RDA);
   ENABLE_INTERRUPTS(INTR_GLOBAL);

to enable the interrupt. Any comments?

Before I declare RS232 like
Code:

#use RS232(UART1A, BAUD=9600, XMIT = PIN_D0 , RCV = PIN_D1 ,  BITS = 8, STOP = 1, PARITY = N, ERRORS)

without declare its RX and TX pins in advance, and that one can send char to PC, but can not generate RX interrupt at all (even no default interrupt).

Any comments on it? Thanks a lot!

Regards
Mark
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Mon Sep 03, 2012 10:34 am     Reply with quote

Quote:

// forget temp and add arg for your stream??
recv[next_RS232_in++] = getc(UART1);
// above index is no wrap protect?? -mem corruption issue ??
// clear_interrupt(INT_RDA);NOT REQ since CCS adds for you @ exit


naughty_mark



Joined: 29 Aug 2012
Posts: 97

View user's profile Send private message

PostPosted: Mon Sep 03, 2012 4:00 pm     Reply with quote

asmboy wrote:
Quote:

// forget temp and add arg for your stream??
recv[next_RS232_in++] = getc(UART1);
// above index is no wrap protect?? -mem corruption issue ??
// clear_interrupt(INT_RDA);NOT REQ since CCS adds for you @ exit




Thanks asmboy
Embarassed I got it, because I didn't include the interrupt header file in the main function so the program can not find RDA interrupt code.. Sorry for my STUPID~~~
Anyway, thanks
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group