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 on PIC18F2620

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



Joined: 25 Jan 2007
Posts: 5

View user's profile Send private message

#INT_RDA on PIC18F2620
PostPosted: Tue Feb 13, 2007 3:01 pm     Reply with quote

I use wireless module to communicate with a pc, it use RS232. My electronic is perfect but i have a problem with my program. I use rda_isr() but i cannot read the receive buffer.

Code:
#include <18F2620.h>
#device adc=8
#fuses NOWDT,WDT128,HS, NOPROTECT, NOIESO, BROWNOUT, BORV21, NOPUT, NOCPD, NOSTVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOEBTR, NOCPB, NOEBTRB, NOWRTC, NOWRTB, NOFCMEN, NOXINST, NOPBADEN, LPT1OSC, MCLR
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=9)

#include "C:\MAX\Marche\marche.h"
#include "C:\MAX\Marche\moteur.c"

int Positions[10][6] = {
                       {1500,1500,1500,1500,1500,1500},
                       {1500,1500,1400,1500,1500,1400},
                       {1625,1600,1400,1600,1600,1400},
                       {1625,1600,1500,1600,1600,1500},
                       {1625,1600,1600,1600,1600,1600},
                       {1500,1500,1600,1500,1500,1600},
                       {1400,1400,1600,1400,1400,1600},
                       {1400,1400,1500,1400,1400,1500},
                       {1400,1400,1400,1400,1400,1400},
                       };

#int_RDA
RDA_isr()
{
   int iCommande = -1;
   int i,j,k;

   iCommande = getc();
   if(iCommande == 0x55)
   {
         ...
   }
}

void main()
{
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   setup_spi(FALSE);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);

   output_bit(PIN_C4, 1);
   output_bit(PIN_C5, 0);

   while(1)
   {
      ...
   }
}



If i transmit 0x55 it receive it but if i try just if(iCommande) it works with anything i transmit.

thanks
Max
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 13, 2007 5:30 pm     Reply with quote

Quote:
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=9)

Why did you specify 9 data bits ? The normal number is 8 data bits.

I suggest that you use this statement instead:
Code:

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


----------------------
Quote:
int Positions[10][6] = {
{1500,1500,1500,1500,1500,1500},
{1500,1500,1400,1500,1500,1400},

In CCS, an 'int' is an unsigned 8-bit integer. So your array declaration
above will not work. You want to store 16-bit values in the array,
so you should declare it as a 'int16' array. Example:
Quote:
int16 Positions[10][6] = {
1500,1500,1500,1500,1500,1500},
{1500,1500,1400,1500,1500,1400},
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