I've a simple question. I'm trying to send a 32-bit word serial on an AT89C1051U. I'm trying to use a for loop and send the LSB each time, and then shift to the right every iteration. This, in theory, would allow me to send each bit no problem. Here's the code I tried, but I kept getting array problems.
for(n=0; n<32; n++) { p3 = y; y >>= 1; }
sorry, here's the whole code:
#include <reg51.h> unsigned long a = 0xFA6; unsigned long b = 0xB82; unsigned long c = 0xE2A; unsigned long d = 0xC30; unsigned long y; unsigned long sum; unsigned long delta; unsigned long n; sbit pin37 = P3^7; int main(){ pin37 = 1; while(1){ sum = 0; delta = 0x9E3779B9; n = 32; y = P1; while(n-->0) { sum += delta; y += (y << 3) + a^y + sum^(y >> 6) + b; } for(n=0; n<32; n++) { y >>= 1; pin37 = y[1]; } } }
for(n=0; n<32; n++) { pin37 = (bit)(y & 1); y >>= 1; }
You showed us the code --- good. But you forgot to tell why you think this code is having "array problems". What's this code's expected behaviour, and what do you see happening instead, at which stage (compile, link, run time)?
"But you forgot to tell why you think this code is having "array problems"." That would be the "Subscript on non-array" message he gets at compile time by trying to access an unsigned long using array subscripting. "What's this code's expected behaviour" Did you actually read this thread?
Thank you very much, that did exactly what I needed it to. Hope someday I can return the favor. Enjoy your day everyone :)