Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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);
}
}
----------------------------------------
 
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
 
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?

/////////////////////////////////////////////////////////////////////////
//// EX_SISR.C ////
//// ////
//// This program shows how to implement an interrupt service ////
//// routine to buffer up incomming serial data. ////
 
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) ?
 
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.

Latest threads

New Articles From Microcontroller Tips

Back
Top