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

hey everyone, if you can help me to correct my errors

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



Joined: 26 Sep 2013
Posts: 4

View user's profile Send private message

hey everyone, if you can help me to correct my errors
PostPosted: Thu Sep 26, 2013 7:37 am     Reply with quote

#include "16F873A.h"
#device ADC=8
#use delay(clock=4000000)
#fuses XT,NOWDT
#use rs232(baud=9600, xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=data)
#int_ext // Interrupt name , External interrupt detect on RB0
void isrext() // Interrupt service routine
{
output_c; // ISR action
delay_ms(10);
}
void main(){
setup_adc_ports(ALL_ANALOG);//configuration des ADC
enable_interrupts(global);//configuration des iterruption
enable_interrupts(int_ext);//configuration interruption sur RB0
ext_int_edge(H_to_L); //FD

setup_uart(19200);//initialiser uart for read and write
float analin[3];
float disvolts[3];
int n;
int i,x,y;
while(true){
for (n=0;n<3;n++)
{
delay_ms(10);
set_adc_channel(n);
analin[n]=read_adc();//get input
x=get_sensor_data(y_axis);
y=get_sensor_data(x_axis);

if (UART1_Data_Ready()) { // If data has been received
i = UART1_Read(); // read it
UART1_Write(i); // and send it back
}
printf(&uart_stream,PSTR("y:f\r\n"));
printf(&uart_stream,PSTR("x:f\r\n"));



output_high(PIN_B1);
delay_ms(500);
output_low(PIN_B1);
delay_ms(500);
}

}
}
stephy



Joined: 26 Sep 2013
Posts: 4

View user's profile Send private message

PostPosted: Thu Sep 26, 2013 8:07 am     Reply with quote

and spatially how do I define the variables n, i, x, y.
Thanks in advance
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Thu Sep 26, 2013 8:27 am     Reply with quote

Hi,

You are off to a bad start as a new forum member. To begin, you should learn to use the 'Code' buttons when posting so that your code remains
properly formatted, and is easy to read. Look at any other post here on the forum, and compare it to yours. Next, we aren't mind readers and a lot of
us don't have time to cut-n-paste your code to try to compile it. Instead, you should tell us the specific errors you are getting, and let us help you that
way! Finally, you should always post your compiler version number!!

John
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Thu Sep 26, 2013 8:41 am     Reply with quote

Code:

analin[n]=read_adc()

assign an INT to a FLOAT ??

the list of problems is much greater than this however

* add "ERRORS" to #use rs232

*enable global ints LAST after the individual are set up

* setup baud with the #USE stmt makes no sense to set 9600, then 19200 in main()

*what happens to execution after the FOR loop ends?

thats just for starters
stephy



Joined: 26 Sep 2013
Posts: 4

View user's profile Send private message

PostPosted: Thu Sep 26, 2013 9:01 am     Reply with quote

hey, thank you john but how can i define my variables n and x,y
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Thu Sep 26, 2013 11:04 am     Reply with quote

Quote:

define my variables n and x,y


you DECLARE them now as ints

do you mean preload them with a VALUE?

as in

int n=77;

also re:

#int_ext

get rid of the delay_ms(10);

and do a dumi read of portb as a byte to clear the ISR properly
stephy



Joined: 26 Sep 2013
Posts: 4

View user's profile Send private message

hey
PostPosted: Thu Sep 26, 2013 11:29 am     Reply with quote

for (n=0;n<3;n++) that's about the variable n
but I didn't understand what about the isr, I know that the isr is for the interruption
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Thu Sep 26, 2013 11:34 am     Reply with quote

since your isr
only outputs port C
( which the rest of the program appears to not have set
to any value)
and ends with a potentially damaging delay

how can your question be answered?

YES there is very much wrong with the program.
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Thu Sep 26, 2013 1:01 pm     Reply with quote

Hi,

At the end of the day, I think you are doing this dude a disservice by spoon-feeding him answers, and not insisting that he employ a methodical process to
troubleshoot his program. He'll probably learn something about this particular program, but the process will repeat the next time.

At a minimum he should tell us (1) what the program is supposed to do, and (2) how the current functionality differs from his expectations. Dumping a
large block of un-formatted code on us, and then saying "can you help find my errors" is not an effective/efficient troubleshooting technique.

John
ckielstra



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

View user's profile Send private message

PostPosted: Fri Sep 27, 2013 6:40 am     Reply with quote

I agree that Stephy should tell us what he wants to do with the program.

I searched Google for the function UART1_Data_Ready() and it turns out this is from the MikroC compiler. Stephy copied code from another project and has no clue as to what he is doing.

My advice is to start with a simple program to blink a LED every second and from there expand your program.
We can help with this but you will have to read a C language book first.
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