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

problem with int_rda()

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
AZ APPS 1
Guest







problem with int_rda()
PostPosted: Sat Feb 14, 2009 11:04 am     Reply with quote

I'm using a pic18f4520 and alphacom as a terminal program.

I'm using the int_rda() to receive a character from the terminal, and then echo it back. The problem is that int_rda() never seems to get called. I never see a response on the terminal and the led that int_rda sets never turns on. When I use the getc and putc functions in main, I get the correct response on the terminal, so I know my rs232 interface is fine. I can also control the led in main, so I know the led is properly connected.

I've tried the routine with and without the #priority statement (which shouldn't be necessary when there's only 1 interrupt), and it doesn't affect the result.

Could someone please tell me why int_rda is not being called?

Here's my code:

#include <18F4520.h>
#device PASS_STRINGS = IN_RAM
#device HIGH_INTS=TRUE
#include <stdio.h>
#include <string.h>

#use delay(INTERNAL=8M, clock=32M)
#fuses INTRC//, DEBUG
#priority rda

struct portb_pin_map {
unsigned short led0;
unsigned short led1;
unsigned short led2;
unsigned short DTR;
unsigned short pic_mode;
unsigned short CTS;
unsigned short reserved;
unsigned short bit7;
} portb;

#locate portb = getenv("sfr:PORTB")

void scope() {
portb.led0=1;
portb.led0=0;
}

//rs232 link to computer
#use rs232(BAUD=9600, XMIT=PIN_C1, RCV=PIN_C0, BITS=8, PARITY=N)

void my_transmit_a(char *tx, int cr) {
int a=0;
while(tx[a]!=NULL) {
putc(tx[a]);
a++;
}
if(cr) putc(13);
putc(10);
}

char data=0;

#INT_RDA
void rda_isr () {
portb.led1=1;
data=getc();
putc(data);
}

void main(void) {
setup_oscillator(OSC_32MHZ);
delay_ms(1000);
disable_interrupts(global);
set_tris_a(0xF7);
set_tris_b(0xF0);
portb.led1=0;
enable_interrupts(INT_RDA);
enable_interrupts(global);
while(1) {
//data=getc();
//putc(data);
}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Feb 14, 2009 1:39 pm     Reply with quote

Quote:
#use rs232(BAUD=9600, XMIT=PIN_C1, RCV=PIN_C0, BITS=8, PARITY=N)

The RDA interrupt only works with the hardware UART. You need to specify
pins C6 and C7 in the #use rs232() statement above, for it to work.
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