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

Pic18F13K22 rda_int Problems

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



Joined: 14 Sep 2003
Posts: 96
Location: Toronto, Ontario, Canada

View user's profile Send private message

Pic18F13K22 rda_int Problems
PostPosted: Sun Jan 17, 2010 5:28 pm     Reply with quote

Hi

Thanks for any help in advance.

I started a new project using the Pic 18F13K22. I cannot get the serial interrupt to activate. I know that code should work because I have used the same code with 18F252 and 18F6722 pics.

I am not posting my project code because it would be too long.

I did some searching in the forum and found this short piece of code written by PCM PROGRAMMER. I tried the code but still does not work.

Compiler Version 4.88 PCH

I modified the code to work with the 18F13K22 chip. The code compiles fine and runs. Output to serial terminal 'Hello World' is observed. But I cannot echo data back by any keys on keyboard via rda interrupt.?

Any Ideas???. Idea

Thanks Again


Code:

#include <18F13K22.H>
#fuses intrc_io, nowdt, noprotect, mclr, nolvp, put, nofcmen, noieso
#fuses borv30, nodebug
#device *=16
#device adc=8

#define FREQ_OSC 8000000
#define BAUD_RATE 9600

#use delay(clock = FREQ_OSC)


#byte PIR1  = 0xf9e
#byte SPBRG = 0xfaf
#byte RCSTA = 0xfab
#byte TXREG = 0xfad
#byte RCREG = 0xfae
#byte TXSTA = 0xfac

#bit TXIF = PIR1.4
#bit RCIF = PIR1.5
#bit CREN = RCSTA.4

//------------------------
// Wait for the hardware UART's transmitter
// to become ready and then send the specified
// character.

void my_putc(char c)
{
    while(!TXIF);
   
    TXREG = c;
}

//------------------------
// Wait for character to be available from the
// hardware UART's receiver and then return it.
// If there is an overrun error, then clear it.

char my_getc(void)
{
    int temp;
    int retval;
   
    while(!RCIF);

    temp = RCSTA;
    retval = RCREG;

    if(bit_test(temp, 1))
    {
        CREN = 0;
        CREN = 1;
    }

    return(retval);
}

//-------------------------
void init_uart(void)
{
    SPBRG = (FREQ_OSC / (BAUD_RATE * 16)) -1;
    TXSTA = 0x26;
    RCSTA = 0x90;
}

#int_rda
void rda_isr(void)
{
    char c;

    c = my_getc();
    my_putc(c);
}

//================================
void main()
{
    init_uart();

    printf(my_putc, "Hello World\n\r");

    enable_interrupts(INT_RDA);
    enable_interrupts(GLOBAL);

    while(1);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jan 17, 2010 9:35 pm     Reply with quote

Quote:
Compiler Version 4.88 PCH

Post your real version. Version numbers are in this format: x.xxx
Jerry I



Joined: 14 Sep 2003
Posts: 96
Location: Toronto, Ontario, Canada

View user's profile Send private message

Pic18F13K22 rda_int Problems
PostPosted: Sun Jan 17, 2010 10:44 pm     Reply with quote

Sorry

Compiler Version 4.088
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 18, 2010 12:18 am     Reply with quote

I'm not sure why you're doing all this register stuff. Why not base your
code on this post here:
http://www.ccsinfo.com/forum/viewtopic.php?t=40214&start=7

I don't have vs. 4.088, but I do have vs. 4.087. I looked at the .LST
file for that version, and the fix for the ANSELx registers is needed.
The rest of it looks like it will probably work.
Jerry I



Joined: 14 Sep 2003
Posts: 96
Location: Toronto, Ontario, Canada

View user's profile Send private message

PostPosted: Mon Jan 18, 2010 7:36 pm     Reply with quote

Thanks Its working.
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