|
|
View previous topic :: View next topic |
Author |
Message |
vcdro
Joined: 17 Jan 2013 Posts: 5 Location: rizal
|
Expecting function name! PIC16F877A speedometer |
Posted: Thu Jan 17, 2013 2:15 am |
|
|
i got this code of speedometer somewhere in the net and i already made some changes to it.. however i really can't figure out what's the problem, can you guys help me out with this?, also, i'm not that familiar with the language so please bear with me if i may look foolish with this... hehe thanks to those who will share their knowledge..
here's the code:
#include <16F877A.h>
#device adc=8
#use delay(clock=4000000)
#fuses XT, BROWNOUT,NOWDT
#include <lcdx.c>
float rpm=0,kmph=0;
int16 count=0,rpmi;
int timer_co=0x00;
unsigned char lcd_buffer[17];
#int_EXT
void EXT_isr(void)
{
count=count+1;
}
#int_TIMER1
void TIMER1_isr(void)
{
timer_co=timer_co+1;
if(timer_co==15)
{
rpm=count*15; // calculating rpm
kmph=rpm*.06;
rpmi=rpm; count=0;
timer_co=0x00;
lcd_putc('\f');
sprintf(lcd_buffer,"%ld",rpmi);
lcd_puts(lcd_buffer,UL);
sprintf(lcd_buffer,"%f",kmph);
lcd_puts(lcd_buffer,UR);
sprintf(lcd_buffer,"rpm");
lcd_puts(lcd_buffer,LL);
sprintf(lcd_buffer,"Kmph");
lcd_puts(lcd_buffer,LR);
} >>>>> expecting function name appear here
} |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Thu Jan 17, 2013 2:33 am |
|
|
1) This is probably the best example of how _not_ to write an ISR I have seen for a while. Repeat this mantra fifty times, stick a bucket on your head, and repeat it again. _Interrupt handlers should be as short as possible_. _They should do just what the interrupt requires them to do, and nothing else_.
2) Look at the syntax of the lines in front of the error. Are you sending the right type of data to the functions?. Are the functions correctly written (you are not using the standard library, so we can't tell). |
|
|
vcdro
Joined: 17 Jan 2013 Posts: 5 Location: rizal
|
|
Posted: Thu Jan 17, 2013 6:52 am |
|
|
actually, from the original code , it was only "EXT_isr and TIMER1_isr" not "void EXT_isr(void) etc." so i guess it's my mistake to put it that way.. i just did that because it had an error "function not void and does not return value" something like that so i assume i corrected that error by putting void on it..
anyway, do you have any idea where should I begin to fix these errors? Thank you for replying., highly appreciated.. |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Thu Jan 17, 2013 7:07 am |
|
|
that code you posted _without code buttons_ is incomplete...
you don't have a "main" function... i only see 2 ISRs and fuses...
I highly doubt it compiles...
looks like you are using the Flex driver... PCM has been kind enough to explain clearly how to use it... i don't see you even including the driver (PCMs or CCS)
EDIT: i found the driver declaration.... my bad.
you have not understood the point made by Ttelmah...
_keep your ISR short_ printing to terminals or to LCDs is _Very_time consuming...
but then again you don't have a main function... so... all of the above is pretty irrelevant...
G. _________________ CCS PCM 5.078 & CCS PCH 5.093
Last edited by Gabriel on Thu Jan 17, 2013 7:55 am; edited 1 time in total |
|
|
vcdro
Joined: 17 Jan 2013 Posts: 5 Location: rizal
|
|
Posted: Thu Jan 17, 2013 7:45 am |
|
|
thank you Gabriel
i just put a main function before but it did not work either.. or maybe i just don't know where should i exactly put the main function on the code..
sorry for my stupidity, i hope you have more patience to answer my questions.. thank you again.. |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Thu Jan 17, 2013 7:52 am |
|
|
the "main" function:
Literally:
Code: | void main()
{
//your code here
} |
is not optional...
I think you are better off starting with a blink program... and then progressing your way into what you want...
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
Re: Expecting function name! PIC16F877A speedometer |
Posted: Thu Jan 17, 2013 8:07 am |
|
|
vcdro wrote: | I got this code of speedometer somewhere in the net and I already made some changes to it.. however I really can't figure out what's the problem, can you guys help me out with this?
|
Ttelmah wrote: |
1) This is probably the best example of how _not_ to write an ISR I have seen for a while.
|
Hi,
I'm going to go a step further, and say this is probably the best example
of how _not_ to learn programming I have seen for a while. Seriously,
this is just incredible. You find a random snippet of code on the "internet"
for which you have absolutely no clue. Now, you modify it without any
clue at all, and surprise, surprise, it doesn't work??? So, then you come
here and expect to be "educated".....
If you have any hope of _ever_ becoming an embedded programmer,
then you need to take about 10 steps back, pick up the manuals, spend
some time reading the forum, and play with some basic projects.
Frankly, what you've done so far is a total joke - and I'd be shocked if
you _ever_ get anything working given your current methodology.....
But, good luck!
John |
|
|
vcdro
Joined: 17 Jan 2013 Posts: 5 Location: rizal
|
|
Posted: Thu Jan 17, 2013 8:12 am |
|
|
That's what i did before and if i'd remember it right it had an error "a numeric expression must appear here"..
hmmm... maybe you're right about me starting with a blink program, i will consider that one... i just thought of knowing about this code because part of my project is about programming and i admit that i'm not that knowledgeably into that..
Thank you again Gabriel for your effort! |
|
|
vcdro
Joined: 17 Jan 2013 Posts: 5 Location: rizal
|
|
Posted: Thu Jan 17, 2013 8:17 am |
|
|
ezflyr,
Thank you for the comment, i will consider your thoughts.. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Thu Jan 17, 2013 9:17 am |
|
|
If you look again at what he posts, he is using a non standard driver (not flex lcd, or the CCS supplied one), called 'lcdx.c'. This is including a puts declaration, which suggests it is for another C, since this is not needed in CCS (with it's ability to printf, to the LCD driver). Then he calls this with a series of values which he does not show the declarations for (UL, LL etc.). Almost certainly a syntax error in this code, hence my comment:
"Look at the syntax of the lines in front of the error. Are you sending the right type of data to the functions?. Are the functions correctly written (you are not using the standard library, so we can't tell).".
Best Wishes |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Thu Jan 17, 2013 11:13 am |
|
|
There is something missing from the ISR to make it a complete endeavor!!!
seriously - I am bereft of where to even start, lacking the code in it's entirety. And since it was "copied" , I have no clue as to where to begin to help......
++++++++++++++++++
To asmboy and all
Please reduce the "pile on" behavior in this and recent threads.
This is a help forum, not a chat forum, and not a snark forum.
Restrain yourself from making a pile-on post.
- Forum Moderator
++++++++++++++++++ |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Fri Jan 18, 2013 4:07 am |
|
|
I've kept out of this one so far.
At the risk of incurring the moderator's wrath, this is my advice.
1) Plagiarizing other's work is usually a waste of time.
2) Do some reading, 'C', CCS manual, PIC data sheets, forum guidelines.
3) Start from simple beginnings.
4) Try out some of the CCS examples, LED blink, UART, LCD, ISR etc.
5) Learn to drive the peripherals for yourself, one at a time.
6) Write your own code.
7) If (when) you get stuck, ask for help on a specific issue.
8) The relatively small number of guys who've contributed to this thread collectively have over a century's experience, don't antagonize or ignore them, treat them with respect.
Mike
EDIT
I don't personally know any of the other guys here, we live all over the globe.
We do occasionally have differences of opinion, but usually there's a concensus.
I've learnt that many of them have been in this game for decades, you can't put a price on their advice, yet they give it freely. |
|
|
|
|
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
|