Hi Brian
It may be an issue with the compiler C programming language standard dialect (eg. C90, C99, C11) used by KDS (it may also be configurable if you play with it) that will not allow you to declare variables in a routine after code.
If you do this instead it may build:
int main(void) {
int i;
int data[] = {1,0,1,1,0,0,0,1};
DDRB |= ((1<<DDB0)|(1<<DDB4));
...
or if you put the second part in brackets it may also be OK:
int main(void) {
DDRB |= ((1<<DDB0)|(1<<DDB4));
...
{
int i;
int data[] = {1,0,1,1,0,0,0,1};
for (....
}
}
I would also make int data[]
static const int data[]
to keep it in flash.
Also, the array looks to be a bit overkill in this case whereby
static const data = 0xb1;
for (i=0x80;i!=0;i>>=1) {
if ((data & i) == 0) {PORTB = 0;}
else {PORTB = (1<<DATA);}
PORTB |= (1<<REG_CLK);
}
is both more efficient and more logical "when thinking in the byte value" to be sent.
Regards
Mark
uTasker developer and supporter (+5'000 hours experience on +60 Kinetis derivatives in +80 product developments)
Kinetis: http://www.utasker.com/kinetis.html