https://en.wikipedia.org/wiki/Subroutine
Write tight code. Meaning determine what the code you're writing is actually doing, and tweak it so that it does it better.
Well I been playing with MikroC and read dang near there whole help file and couldn't fine a thing to point me right. But i think I'm on the right track now
I wrote that piece and complied it and it said that main was a empty sub. Lol it was . Thanks Mike And Sceadwian
Now all i need is to figure how to do a bound In C
Like Send out 0b10101010 out A GPIO.B0 one bit at a time
Code:
int i;
i=8;
while (i)
{
GPIO.B0 = data>>1;
i--;
SClock=~SClock;
}
for(i=0;i<8;i++){ //for 0 to 7
GPIO.B0 = data&1; //send out bit zero
data>>=1; //shift data right 1 bit
SClock=~SClock; //doesn't this need to be 1 then 0
}
Bound just lets you set it to what your sending so you don't have to set 0 to7 it would 0 bound to Data and it's size. Thanks Mike I feel like a real dummy I should of thought about a for loop.
I for loop would work great seeing I can't send more then 8 bits at a time. Thanks agin Mike.
Dang the joy of a New compiler reserve words I new i wasn't that dumb data is a reserve word. My code worked Mikes code works and now it back to doing something useful. I'll post the whole thing when I get done it's a two wire LCD.
Yep I got the idea i could use data as a variable from your site MrRB.I it worked before but I'm using the 4.80 beta. Funny how simple things seem to get me LOL
I slapped this baby in a nice do loop so it would row along and so far so good
Code:
#define SClock GPIO.B1
unsigned char Sdata;
unsigned char i;
void main() {
OSCCON = 0x72;
TRISIO = 0b00000000;
CMCON0 = 7; // no comparator
ANSEL = 0x00;
do {
Sdata =0b01010001;
for(i=0;i<8;i++){ //for 0 to 7
SClock=0;
GPIO.B0 = Sdata&1; //send out bit zero
Sdata>>=1; //shift data right 1 bit
asm nop;
SClock=1; //doesn't this need to be 1 then 0
}
} while (1);
}
Whoops! Thanks for the heads up! I will edit that page and change the variable name "data" to "sdata" or something that will work with the new compiler.