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

Serial Interrupt NOT WORKING

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



Joined: 25 Oct 2007
Posts: 7
Location: Puebla Mexico

View user's profile Send private message

Serial Interrupt NOT WORKING
PostPosted: Fri Apr 18, 2008 12:09 pm     Reply with quote

Hi there everybody, im trying to make a simple echo program but i just cant receive data from PC, i do send data from the PIC to the PC, but i cant receive the data from the PC, here is the code is very simple. I have read already many similar post but can't get it to work, thanks for all post Very Happy

Code:

#include <18F4520.H>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
BYTE value;
#int_rda
void rda_isr(void)
{
value=getc();
printf("%d",value);

}   

//========================
void main()
{

enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
 
while(TRUE)
{
delay_ms(1000);
printf("Sending");

}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 18, 2008 12:15 pm     Reply with quote

Try this improved version of your test program. Notice the several
changes. With this program, you can type in characters at your
serial terminal window (HyperTerminal) and watch it be sent back
by the PIC and displayed in the window.
Code:
#include <18F4520.H>
#fuses XT,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#int_rda
void rda_isr(void)
{
int8 c;

c = getc();
putc(c);

}   

//========================
void main()
{
printf("Start: ");

enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
 
while(1);
}
AntonioB



Joined: 25 Oct 2007
Posts: 7
Location: Puebla Mexico

View user's profile Send private message

PostPosted: Mon Apr 21, 2008 10:10 am     Reply with quote

hi, well i already tried that but i didnt work, maybe its my computer, im going to check, because i do can send info from the pic to the PC but can't get the echo working, i'll post what i find once i know, thanks for the help.
Matro
Guest







PostPosted: Mon Apr 21, 2008 10:56 am     Reply with quote

In your #use rs232, set BIT, STOP and PARITY parameters to appropriate values.
Could you also post a quick description of your hardware?

Matro
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 21, 2008 11:33 am     Reply with quote

Quote:
In your #use rs232, set BIT, STOP and PARITY parameters to appropriate values.

You don't really have to do that. The CCS library defaults to 8 bits,
1 stop bit, and no parity. It's been that way for years.
Matro
Guest







PostPosted: Mon Apr 21, 2008 11:39 am     Reply with quote

PCM programmer wrote:
Quote:
In your #use rs232, set BIT, STOP and PARITY parameters to appropriate values.

You don't really have to do that. The CCS library defaults to 8 bits,
1 stop bit, and no parity. It's been that way for years.

I could agree with you if we knew the setting used by the poster. But here we don't know, so I did this proposal.

Matro.
AntonioB



Joined: 25 Oct 2007
Posts: 7
Location: Puebla Mexico

View user's profile Send private message

PostPosted: Mon Apr 21, 2008 3:44 pm     Reply with quote

Hi there, yes im using for default 8 bits, 1 stop bit, 9600 baud rate, and none parity , but i still cant get the interruption to work, i dont know if the problem is my cable or what, because i already try a program that does an echo but using a CCS Kit, and it worked properly so the computer is working fine, i dont know what the problem is Confused
Gerhard



Joined: 30 Aug 2007
Posts: 144
Location: South Africa

View user's profile Send private message Send e-mail

PostPosted: Mon Apr 21, 2008 4:04 pm     Reply with quote

Can you give some more info on the hardware that you are using between the pic and the pc?
Are you using a max232 chip and so on.
AntonioB



Joined: 25 Oct 2007
Posts: 7
Location: Puebla Mexico

View user's profile Send private message

PostPosted: Mon Apr 21, 2008 4:32 pm     Reply with quote

Hi there, yes I'm using a Max32, but I finally made it work, the problem was the cable!!!, I changed it and now is working verry good, thanks all for the help Razz Very Happy Laughing
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