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

issue with INT_RDA

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







issue with INT_RDA
PostPosted: Wed May 27, 2009 9:52 am     Reply with quote

hi,

i want to send some stuff to a pic with a computer, and it was working, until i tried to do it with interrupts

here is my working code

Code:

#include <16F876A.H>
#fuses HS, NOWDT, NOPROTECT, /*BROWNOUT,*/ PUT, NOLVP
#use delay(clock = 20000000)
#USE RS232(BAUD=9600, XMIT=PIN_c6, RCV=PIN_c7, PARITY= N, bits = 8,errors)

#include <FullCms_Variables.c>
#include <FullCms_LcdDrivers.h>

void main (void)
   {
   char cara;
   int counter=0;
   char reception[] = "-reception-";
   delay_ms(100);
   lcd_init();
   lcd_send_stringc(reception,1);
   lcd_curseur_pos(1,2);
   LCD_curseur_on();
   while(1)
      {
      cara = getc();
      lcd_send_car(cara);
      counter++;
      if(counter ==16)
         {
         lcd_clear();
         lcd_send_stringc(reception,1);
         lcd_curseur_pos(1,2);
         counter =0;
         }
      }
   }


and when i add those line :

just before the main
Code:

#byte RCREG = 0x1A

#INT_RDA
void rda_isr(void)
   {
   RDA_Flag = 1;
   }



just before the LCD_init();

Code:

   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);


my code isn't working anymore

what did i do wrong?

thanks

ps i'm using CCS V4.057
suraidaa
Guest







PostPosted: Wed May 27, 2009 10:29 am     Reply with quote

problem almost solved

i tough that an interrupt was generated each time a data packet was received, but in fact, an interrupt is generated each time the RCREG register is full

since i wasn't reading him inside the interrupt, INT_RDA was ignited each cycle

my new code is :

Code:

#include <16F876A.H>
#fuses HS, NOWDT, NOPROTECT, /*BROWNOUT,*/ PUT, NOLVP
#use delay(clock = 20000000)
#USE RS232(BAUD=9600, XMIT=PIN_c6, RCV=PIN_c7, PARITY= N, bits = 8)

#include <FullCms_LcdDrivers.h>

int RDA_flag = 0;
char cara;

#byte RCREG = 0x1A

#INT_RDA
void com_isr(void)
   {
   RDA_Flag = 1;
   cara = RCREG;
   }

void main (void)
   {
   char cara;
   int counter=0;
   char reception[] = "-reception-";
   
   
   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);

   
   delay_ms(100);
   lcd_init();
   lcd_send_stringc(reception,1);
   lcd_curseur_pos(1,2);
   LCD_curseur_on();
   while(1)
      {
      if (RDA_Flag == 1)
         {
         RDA_Flag = 0;
         Counter++;
         lcd_send_car(cara);
         if (counter == 16)
            {
            counter = 0;
            lcd_clear();
            lcd_send_stringc(reception,1);
            lcd_curseur_pos(1,2);
            }
         }
      }
   }


new issue, cara is containing a weird char insted of what i'm suposed to received
suraidaa
Guest







PostPosted: Wed May 27, 2009 10:58 am     Reply with quote

problem solved^^

i was re-declaring "cara" inside the main, thus there was 0 inside everytime

even if you didn't help me directly, i found all my awnser inside this wonderfull forum

thanks
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