jrz126
Active Member
I've got my first assignment due on tues for my microcontrollers class and Im having a hell of time with it...
the question: Create a program using do-while loop, the program will print the power of 2 from 2^0 to 2^12 on the PC screen. The printed strings should be like "2 to the power of xx = xxxx \n"
I've got the serial comm. figured out, but I cant figure out how to do the power function. here's what I thought I could use:
but it gives me an error about it being too big for the ROM.
Also, are there any good websites with C-based pic projects? Seems like everybody uses assembly...well everbody except my professor
the question: Create a program using do-while loop, the program will print the power of 2 from 2^0 to 2^12 on the PC screen. The printed strings should be like "2 to the power of xx = xxxx \n"
I've got the serial comm. figured out, but I cant figure out how to do the power function. here's what I thought I could use:
Code:
#include <16F877.h>
#use delay(clock=10000000) //External clock 10MHz
#fuses HS, NOWDT //High speed, no watchdog timer
#use rs232(baud=9600, xmit=PIN_c6, rcv=PIN_C7)
#include <stdio.h>
#include <math.h>
void main()
{
float i=0;
float newval;
do
{
newval=pow(2,i);
printf("2 to the power of %f = %f \n",i,newval);
i=i+1;
} while (i<12);
}
but it gives me an error about it being too big for the ROM.
Also, are there any good websites with C-based pic projects? Seems like everybody uses assembly...well everbody except my professor