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

How to separate char?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Tue Apr 17, 2012 4:39 am     Reply with quote

Obvious things.

First _do not try to use things like string functions inside the interrupt_. Unless you know _exactly_ what you are doing, the rule for interrupts should be _just do the actual job the interrupt requires, and get out again ASAP. So a serial receive interrupt, should receive the character, and nothing much else.

Second, use a legitimate syntax for printf. The format string is _not_ optional.

Best Wishes
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Apr 17, 2012 5:26 am     Reply with quote

Quote:

I try this but it not work

Please read the CCS forum guidelines.

What does not work?
What does happen?
What happens that shouldn't?
What is the size of your arrays called first and second?

Explain what you are trying to do.

Make it easy for us to help you.

For instance your original '1/100'
Quote:

Getc=1/100-------> rs232


Won't fit into your char array, (if indeed that is what you are trying to do).
Code:

#define BUFFER_SIZE 5
char array[BUFFER_SIZE]; 

The array will hold FOUR characters plus the terminating zero.

You character string '1/100' is FIVE characters.

Mike
darkrush



Joined: 29 Sep 2011
Posts: 18
Location: Colombia

View user's profile Send private message

PostPosted: Tue Apr 17, 2012 10:54 am     Reply with quote

I know the discussion about malloc ended, but for reference add:
Code:

#include <string.h>
#include <stdlib.h>
#include <stdlibm.h>


Now to the topic, for what I have read, do you know when your data ends? for example 10/200+CR+LF so you can collect the whole string inside the interrupt and the process it.

Or as Mike suggested, just fill the string, like:
Code:

second[i++]=getc();


If you can control the Tx you have to set some rules to make the Rx easier.

Xavier
matsuo



Joined: 17 Feb 2012
Posts: 11

View user's profile Send private message

PostPosted: Tue Apr 17, 2012 9:37 pm     Reply with quote

darkrush wrote:
I know the discussion about malloc ended, but for reference add:
Code:

#include <string.h>
#include <stdlib.h>
#include <stdlibm.h>



it's work but i have some a problem how to reset or clear c1,c2 Very Happy
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Apr 18, 2012 3:17 am     Reply with quote

matsuo wrote:
darkrush wrote:
I know the discussion about malloc ended, but for reference add:
Code:

#include <string.h>
#include <stdlib.h>
#include <stdlibm.h>



it's work but i have some a problem how to reset or clear c1,c2 Very Happy

Matsuo, I'm starting to lose interest in this thread...
Several experienced programmers told you not to use malloc because it is a bad tool on the small PIC processors. You didn't comment on this but continue to use malloc. This gives me the feeling we are talking to a brick wall and are wasting our time.

Here on this forum we teach people to solve their own problems. If you rather prefer a quick answer than it is me just doing my daily job; you can hire me for $100 / hour. The choice is up to you.

You posted your own non-working code. Tips on fixing this code were given. Do something with it!
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Wed Apr 18, 2012 3:47 pm     Reply with quote

You're getting good at this.

You've already started several threads along the same lines.

You ask for help, get loads, then ignore it.

If you don't follow the CCS forum guidelines and make it easy for us to assist you, I shall avoid matsuo posts, end of.

Mike
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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