View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Aug 12, 2009 12:28 pm |
|
|
Post a little test program that shows the problem. Example:
Code: | #include <16F877.H>
#fuses HS, NOWDT, BROWNOUT, PUT, NOLVP
#use delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//====================================
void main()
{
printf("Hello World\n\r");
while(1);
}
|
The program that you post should not be much longer than that. |
|
|
JimB
Joined: 25 Aug 2005 Posts: 65 Location: Huntington Beach, CA
|
|
Posted: Wed Aug 12, 2009 12:56 pm |
|
|
The inital print statements are as follows:
Code: |
setup_adc_ports(AN0_AN1_VSS_VREF);
setup_adc(ADC_CLOCK_DIV_8);
set_adc_channel(1);
delay_ms(300);
batvolt = read_adc();
volt=batvolt*0.00379;
printf("%2.2f Volts\n\n\r",volt);
printf("Done\n\r"); |
Then inside the while loop, this is the print statement:
Code: |
totalsum=totalsum/4;
printf("%lu\n\r",totalsum); |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Aug 12, 2009 1:00 pm |
|
|
Post a complete, compilable test program. Don't post code fragments.
Just add an #include, #fuses, #use delay(), and any other required #use
statements. Add a main(). Add a while() loop. Test it. Prove that it
fails. Post it. Tell what the failure is. Post your compiler version so we
can duplicate the problem. |
|
|
JimB
Joined: 25 Aug 2005 Posts: 65 Location: Huntington Beach, CA
|
How to implement the pushbutton |
Posted: Wed Aug 12, 2009 2:07 pm |
|
|
Since there will not be a pushbutton. How would you recommend simulating that? Remember it behaves differently when pushed quickly for a single reading than when it is held down for multiple readings. The single readings line up side by side and when the button is held down they readout in a column, which is what I expect from the \n\r. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
JimB
Joined: 25 Aug 2005 Posts: 65 Location: Huntington Beach, CA
|
Fixed the first printf() problem |
Posted: Sat Aug 15, 2009 2:03 pm |
|
|
I fixed the first printf() problem. In that one I control the RS232 transceiver to conserve battery power. I just had it turned off. Duh.
However, the second problem that occurs inside of the while loop is a bit more puzzling. I haven't had the time to generate a simple equivalent of that section or code to post here. Problem is that repeated quick pushes causes the output to print side by side on the screen, as if there is no \n\r recognized. If the push is held down allowing the loop to keep starting over, the data is then printed in column form. If I can't figure that one out, I will have to put something here that simulates it.
Thanks for the help, though. |
|
|
|