16f628A int_rda interrupt problem in CCS C

Status
Not open for further replies.

kbaser

New Member
Hi,
I have a cLCD driver circuit which is attached PC's Tx port directly to MCU's hardware Rx port (RB1) by a 22k only (without MAX232C ..etc)
My problem is
when I set the MCU for an int_rda interrupt and send some chars fromm PC to MCU it does not call the interrrupt void function.
Do you think that it is because of direct 22k ?
Does it run when I add a MAX232 between Pc and Mcu?
please help
thanx

My code piece ;
------------------------------------
...
#int_rda
void comm_test() {
disable_interrupts(int_rda);
...
}

void main() {
...
enable_interrupts(GLOBAL);
while(1) {
enable_interrupts(int_rda);
}
}
----------------------------------------
 
How do you know it isn't calling the interrupt? (I mean what method are you using to tell?)
 
actually I set
#use rs232 (baud=2400, rcv=pin_b1, INVERT)
by using invert, I can handle rs232 connections and I can see the coming data by
gets() and getch() methods in an endless while loop.
I want to use "int_rda" instead of while loop (to detect the coming data from PC)
kB
 

I guess you posted while I was posting.
your code sample doesn't show your use of getch() and you need the while loop, else your PIC will go to sleep ... which should not affect this...

EDIT: do you have the example 'EX_SISR.C' in your examples directory?

 
Last edited:
Hi again,
I tried ex_sisr.c example unfortunately I can not handle the int_rda interrupt.
Please check my simple code (with no int_rda) which works well below ;
--------------------------------------------
#include <16F628A.H>
#fuses INTRC_IO, NOWDT, NOPROTECT, PUT,NOMCLR,NOBROWNOUT
#use delay(clock = 4000000)

#include "flex_lcd420.c"

#use rs232 (baud=2400, rcv=pin_b1, INVERT)

char data[20];

void main() {
lcd_init();
while (TRUE) {
gets(data);
printf(lcd_putc,data);
}

}
----------------------------------
and here is the code pieces which I added to ex_sisr ;

...
#int_rda
void serial_isr() {
int t;

//added to blink on interruption
output_low(pin_b0);
delay_ms(1000);
output_high(pin_b0);

...



void main() {

//added to blink on startup
output_low(pin_b0);
delay_ms(1000);
output_high(pin_b0);

enable_interrupts(int_rda);
// #if defined(__PCD__)
// enable_interrupts(intr_global);
// #else
enable_interrupts(global);
// #endif
...
-----------------------------------
In the second example I see led blinking in main(), but no blinking in serial_isr() during serial data send.
Please help why this hardware usart doesn't work but software working ?

kB
 
Your problem is here:
#int_rda
void serial_isr() {
int t;

...
delay_ms(1000);
...
Please help why this hardware usart doesn't work but software working ?

kB

A one second blocking delay in an interrupt is asking for trouble. Interrupts should be as short as possible.

You should put the second delay in your main line code
 
Last edited:
Okay, I remove the

delay_ms(1000);
output_high(pin_b0);

lines in interrupt. I just left
output_low(pin_b0);
line. But unfortunately I can see nothing during serial data transfer.
I mean this interrupt is never caught during serial data transfer.

Does anybody tried "int_rda" interrupt working with direct connection from Pc(tx) to 16F628A(rx) through 22k (no MAX232 IC) ?
 

I have never tried with out using a max chip, and it has been a long time since I've used ccs c.
The problem may be that you need to define both a receive and transmit pin. Try it this way:
Code:
#use rs232 (baud=2400,xmit=PIN_B2, rcv=pin_b1, INVERT)
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…