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

16F688 and 16f627A issues

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



Joined: 29 Aug 2007
Posts: 87

View user's profile Send private message

16F688 and 16f627A issues
PostPosted: Wed Aug 29, 2007 8:59 am     Reply with quote

Hi,
I've been working with CCS compiler V4.0.038 and I have a very strange problem. I have basically the same code as you can you above for the 627A and for the 688. But with the 16F627 in the rs232 port I receive the same characters I send. But with the 688 the characters are all wrong. Does anybody know why is this happening?

Code for 627A
Code:

#include <16F627A.h>

#fuses INTRC_IO, NOWDT, NOPROTECT, NOMCLR, NOBROWNOUT, NOCPD, PUT

#define max_buf_length      10

#use delay(clock=8000000)
#use rs232(baud=1200, parity=N, xmit=PIN_B2, rcv=PIN_B1, bits=8, errors)

int8 rcv_data[max_buf_length] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
int8 rcv_pointer = 0;
int8 pos_eeprom = 0;
short int values_rcv = 0;

#int_RDA   // rs232 receive data available
void RDA_isr(void)
{
   int8 ch = 0;
   ch = getchar();
   rcv_data[rcv_pointer++] = ch;            // store data
   if (rcv_pointer == 10)
   {
      values_rcv = 1;
   }
}

void main(void)
{   
   int8 i = 0;
   port_b_pullups(TRUE);
   set_tris_b(0x01); // PIN_B1 as input
   setup_vref(FALSE);
   disable_interrupts(INT_RDA);
   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);
   while (1)
   {
      if (values_rcv == 1)
      {
         for (i = 0; i < rcv_pointer; i++)
         {
            write_eeprom(pos_eeprom++, rcv_data[i]);
            rcv_data[i] = 0;   // cleaning the buffer
         }
         pos_eeprom = pos_eeprom + 2;
         values_rcv = 0;   // reset variables
         rcv_pointer = 0;
      }
   }
}


Code for 688

Code:

#include <16F688.h>

#device *=16
#device adc=8

#fuses INTRC_IO, NOWDT, NOPROTECT, NOMCLR, NOBROWNOUT, NOCPD, PUT, NOIESO, NOFCMEN

#define max_buf_length      10

#use delay(clock=8000000)
#use rs232(baud=1200, parity=N, xmit=PIN_C4, rcv=PIN_C5, bits=8, errors)

int8 rcv_data[max_buf_length] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
int8 rcv_pointer = 0;
int8 pos_eeprom = 0;
short int values_rcv = 0;

#int_RDA   // rs232 receive data available
void RDA_isr(void)
{
   int8 ch = 0;
   ch = getchar();
   rcv_data[rcv_pointer++] = ch;            // store data
   if (rcv_pointer == 10)
   {
      values_rcv = 1;
   }
}

void main(void)
{   
   int8 i = 0;
   port_a_pullups(TRUE);
   set_tris_c(0x20); // PIN_C5 as input
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_comparator(NC_NC);
   setup_vref(FALSE);
   setup_oscillator(OSC_8MHZ);
   disable_interrupts(INT_RDA);
   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);
   while (1)
   {
      if (values_rcv == 1)
      {
         for (i = 0; i < rcv_pointer; i++)
         {
            write_eeprom(pos_eeprom++, rcv_data[i]);
            rcv_data[i] = 0;   // cleaning the buffer
         }
         pos_eeprom = pos_eeprom + 2;
         values_rcv = 0;   // reset variables
         rcv_pointer = 0;
      }
   }
}


Any help will be appreciate

Thanks in advance
SET



Joined: 15 Nov 2005
Posts: 161
Location: Glasgow, UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Aug 30, 2007 9:04 am     Reply with quote

Quote:
Code:
set_tris_c(0x20); // PIN_C5 as input


I'm guessing you tried this in case the compiler wasn't setting Rx as an input? Shouldn't be required..

Quote:
But with the 16F627 in the rs232 port I receive the same characters I send. But with the 688 the characters are all wrong.

Are you missing some code? Your code puts the Rx'ed chars in EEPROM, so maybe the problem lies there?
ralph79



Joined: 29 Aug 2007
Posts: 87

View user's profile Send private message

PostPosted: Thu Aug 30, 2007 9:21 am     Reply with quote

Hello,

Thanks for your response.

The set_tris_a was my ultimate test. I know that it shouldn't be required but ... I've already try everything.

This code is just a very small part of complex program.
I receive the chars from a RF receiver and, for a test, I save them to the eeprom. With this I want to know if there are any differences between the characters that I send and characters I receive during the time. With the 16F627A I don't have any trouble. But with the 688 I can't get it to work properly.
Is there any other initialization or function that I need to put in my code do get this work? Or in other words what I missed?

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