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 CCS Technical Support

INT_RDA never fires

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



Joined: 09 Nov 2010
Posts: 8

View user's profile Send private message

INT_RDA never fires
PostPosted: Tue Nov 09, 2010 5:04 am     Reply with quote

Hi everybody, here is my problem.
I'm using pic18F2620 PCWHD v.4.068.
I setted up a USART , but when I send a character via Hyperterminal nothing happens, the USART never starts its IRQ. I'm getting mad trying figure it out...
I checked out the forum but nothing solved the problem...
Below is my code

Code:

#include <18f2620.h>
#device ADC=10
#device ICD=TRUE

#include <stdlib.h>
#use delay(clock=4000000)                     
#fuses XT,NOWDT,BROWNOUT,PUT,NOPROTECT,NOLVP,NOCPD

#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, parity=n,ERRORS)


#INT_RDA
void rs232(){
printf("USART fires \n");
}

void main(){

enable_interrupts(INT_RDA);
disable_interrupts(GLOBAL);

while(1){}
}


Please help me :-(
ralph79



Joined: 29 Aug 2007
Posts: 87

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 5:11 am     Reply with quote

try something like this
Code:

#include <18f2620.h>
#device adc=10
#FUSES NOWDT, WDT128, INTRC_IO, NOPROTECT, IESO, BROWNOUT, BORV42, PUT, NOCPD, STVREN, NOLVP, NOWRT, NOWRTD, NOEBTR, NOCPB, NOEBTRB, NOWRTC, NOWRTB, FCMEN, NOXINST, PBADEN, LPT1OSC, NOMCLR
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, parity=n,ERRORS)
curry



Joined: 09 Nov 2010
Posts: 8

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 5:18 am     Reply with quote

Doesn't work.....anyway my 18F2620.h file doesn't have BORV43, I used BORV42....I don't think this is a problem.....
temtronic



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

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 6:17 am     Reply with quote

will it do a 'blinking LED program'?

do you have a MAX232 in the serial ports, wired correctly ?

can the 'icd=true' interfere with the serial stuff ?

does 'disable global interrupts' disable ALL the interrupts ????
curry



Joined: 09 Nov 2010
Posts: 8

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 6:43 am     Reply with quote

It doesn't blink a LED....I just wanna try the UART interrupt in order to use it in a bigger code.
I tried to disable ICD: the problem still remains.
Yes you're right it's not disable_interrupts(GLOBAL) but enable_interrupts(GLOBAL).
Here the corrected code:

Code:

#include <18f2620.h>
#device ADC=10
#device ICD=TRUE

#include <stdlib.h>
#use delay(clock=4000000)                     
#fuses XT,NOWDT,BROWNOUT,PUT,NOPROTECT,NOLVP,NOCPD

#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, parity=n,ERRORS)


#INT_RDA
void rs232(){
printf("USART fires \n");
}

void main(){

enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);

while(1){}
}
curry



Joined: 09 Nov 2010
Posts: 8

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 6:46 am     Reply with quote

Forgot a thing: no MAX, I use FT232RL, a USB to serial UART interface.
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 7:43 am     Reply with quote

Try reading the incoming char in the ISR with getchar(), and shouldnt you declare your ISR function before you define it?

also... dont print inside the ISR....set a flag... print outside when flag is set....

just my 2 cents...
_________________
CCS PCM 5.078 & CCS PCH 5.093
curry



Joined: 09 Nov 2010
Posts: 8

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 8:06 am     Reply with quote

getchar() used.....printing outside with a flag setted in the ISR... but nothing anymore :-(

I don't need to declare the ISR function since put it in under #INT_RDA: always seen like this in thousand of examples and CCS manual
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 8:27 am     Reply with quote

well... i do declare my ISR function... and my code works....
i can only suggest you try it... how much time could that take?
is it not worth a try?


this is from an old program i made:
Function: void SerialInt();

Code:
#elif defined(__PCM__)
#include <16f877a.h>
#include <string.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT,NOPUT
#use delay(clock=20000000) //must be 20 MHz

#use rs 232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // serial


void SerialInt();          // USART INT handler
int TEST_AT();            // Test Modem
int SET_MEM();            // Set used memory


once you declare it, you still need to place it under #INT_RDA
_________________
CCS PCM 5.078 & CCS PCH 5.093
curry



Joined: 09 Nov 2010
Posts: 8

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 8:46 am     Reply with quote

Tryed....but it doesn't work
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 9:06 am     Reply with quote

... do you have an O-scope? check if your comm is working properly?

blink a led on your main code to make sure you pic is running..

... i cant really think of anything else...
_________________
CCS PCM 5.078 & CCS PCH 5.093
curry



Joined: 09 Nov 2010
Posts: 8

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 9:18 am     Reply with quote

If could be useful......I tryed to read the first character in the main, and store it in a dummy variable: suddenly the interrupt start firing with successives chars sent ...the problem now is that in this way I have to waste the first data in the dummy variable; instead when IRQ is called i need the first data to be read, in order to choose then with a switch-case statement, the portion of code to execute.....any suggestions?
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 10:08 am     Reply with quote

post new code....
_________________
CCS PCM 5.078 & CCS PCH 5.093
temtronic



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

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 2:30 pm     Reply with quote

Since you're not using a real (old school, board level) rs232 comport but a USB converter, have you tried a loopback on the serial side and confirmed that your PC serial software is properly working through the USB-serial converter chip?
I've got two of those devices here, one works fine the other doesn't, so I have very,very little faith in those products. There's a LOT of overhead in USB and maybe it's setup is corrupted. Even Hyperterminal will confirm a simple ...press a key, send to the comport...to USB..out...loopback into
USB...back to comport...back to Hyperterminal to display the key pressed.
Also is the 'serial' side of the converter RS-232 signaling or TTL signaling? If TTL, you'll have to say 'invert' in the PICs use rs232 statement...
curry



Joined: 09 Nov 2010
Posts: 8

View user's profile Send private message

PostPosted: Wed Nov 10, 2010 1:49 am     Reply with quote

Solved........the pic and USB-UART interface I am using, have flow control wires tied as well: I forgot to set CTS in order to get data........
Thanks all for your tips....good work guys
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