View previous topic :: View next topic |
Author |
Message |
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Tue Apr 17, 2012 4:39 am |
|
|
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
|
|
Posted: Tue Apr 17, 2012 5:26 am |
|
|
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
|
|
Posted: Tue Apr 17, 2012 10:54 am |
|
|
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
|
|
Posted: Tue Apr 17, 2012 9:37 pm |
|
|
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 |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Apr 18, 2012 3:17 am |
|
|
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 |
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
|
|
Posted: Wed Apr 18, 2012 3:47 pm |
|
|
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 |
|
|
|