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 support@ccsinfo.com

Interrupt Service Routine blocks microcontroller

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



Joined: 06 Sep 2011
Posts: 1

View user's profile Send private message

Interrupt Service Routine blocks microcontroller
PostPosted: Tue Sep 06, 2011 10:02 am     Reply with quote

Hi everyone! I'm developing a project with pics and now I'm testing serial communication through rs232, using a pic, a max232 converter and my laptop.
The problem is simple to explain, but i don't know how to get over it and what I'm doing wrong.
When I establish a communication without using interrupts (Interrupt Service Routine), the communication works just fine. The problem is that I need to use the ISR on the main project. To test the communication with ISR, I created this simple program, but it doesn't work.
Can someone see any programming error or have any suggestion to help me solve this situation?
I'm using MPLAB IDE to develop code, using the compiler HI-Tech ANSI C Compiler.
Thanks in advance!


Here goes the code:
Code:

#include <htc.h>

#if defined(_16F877)

__CONFIG(UNPROTECT & XT & DEBUGDIS & LVPDIS & WDTDIS & PWRTDIS & LVPDIS & BORDIS);
#endif

void RS232Conf(void);
void DataArrival(unsigned char Data);
void interrupt rsi(void);
void RS232Tx(unsigned char Tx);

void main(void)
{
unsigned char Rx;

SYNC=0;
TX9=0;
CREN=1;
TXEN=1;
SPEN=1;
BRGH=1;
SPBRG=25;
TRISB=0;
RCIF=0;
TXIF=0;
RCIE=1;
TXIE=0;
PEIE=1;
GIE=1;

RS232Tx('h');
RS232Tx('i');
RS232Tx('!');

while(1)
{
RB3=1;
if(RCIF==1)
{
Rx=RCREG;
DataArrival(Rx);
}
}
}

void DataArrival(unsigned char Data)
{
TXREG=Data;
}


void RS232Tx(unsigned char Tx)
{
while(TRMT==0);
TXREG=Tx;
TXIF=0;
}

void interrupt rsi(void)
{
unsigned char Rx;

if(RCIF==1)
{
Rx=RCREG;
DataArrival(Rx);
}
}
temtronic



Joined: 01 Jul 2010
Posts: 9177
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Sep 06, 2011 10:53 am     Reply with quote

Well your first if not biggest mistake is posting your HiTech compiler problem on this forum !!

This is the CCS C compiler forum and while many of us could easily help perhaps you should ask the HiTech forum, unless of course you already have and got no help. If that's the case, buy the CCS version for your PIC and 'welcome onboard'. CCS provides TONS of working source code including several ISR programs including buffered serial I/O reoutines.!!
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