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

Strings and ex_sisr.c

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



Joined: 11 Jul 2006
Posts: 42
Location: Minden, Germany

View user's profile Send private message

Strings and ex_sisr.c
PostPosted: Tue Apr 03, 2007 2:02 am     Reply with quote

Hi all!
I have a question. I send a string from PC to PIC via rs232. It looks like "03.04.2007". It should be storaged in internal eeprom from PIC16F877A. Can i use this example (ex_sisr.c) to receive this string and write it to eeprom?

Thank you. Regards. Dennis
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Tue Apr 03, 2007 8:11 am     Reply with quote

Dennis,

Yes, the ex_sisr.c is a good starting point for what you are trying to do. When you send a string from the PC to your PIC you'll need to add a 'marker' to the end of the string to let the PIC know that, that is the end of the incoming string. Usually a CR or a LF is used.

Try doing a search for 'kbhit' in the forum and look at the code in the posts that are returned. You might find some good examples.

John
deniska_gus



Joined: 11 Jul 2006
Posts: 42
Location: Minden, Germany

View user's profile Send private message

PostPosted: Wed Apr 04, 2007 12:11 pm     Reply with quote

Hallo all!

Here i made a interrupt service routine, that should read a string from rs232. But something is wrong, but what? My µC program should read a string, that i try to send from PC. It looks like "20.04.2007&", for example.
Code:

include <16F877a.h>
#fuses XT,NOWDT,PROTECT,PUT,BROWNOUT,NOLVP,NOWRT
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_c6, rcv=PIN_c7,parity=n,bits=8,ERRORS)
#use i2c(Master, sda=PIN_C4, scl=PIN_C3, SMBUS)

#include <stdlib.h>
#include <string.h>
#include <input.c>

#define BUFFER_SIZE 30
char buffer[BUFFER_SIZE];
char string[15];
BYTE next_in = 0;
#int_rda

void serial_isr()
{
  buffer[next_in]=getc();

   if(buffer[next_in] == '&')   
   {
    buffer[next_in] = '\0';
    strncpy(string, &buffer[next_in]-10, 10);
   }
 
   next_in=(next_in+1);
}

void main()
{
 
  enable_interrupts(global);
  enable_interrupts(int_rda);
  while(1)
  {
   
  }
}
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