Hi, Currently doing a project for college and have come to a road block. I have function which has a if statement. There are five different possible outcomes for the if statement. The outcome depends on four different inputs, the fifth one is null. The problem i'm having is I don't want to come out of the if statement if there's no change to the input. I'm using a do while statement with the if statement. temp_read is the variable I store the value of which if statement is being used. Hope someone understands what i'm trying to say.
Thanks Thomas
void read_braking(void) { unsigned char temp_read; unsigned char total_secs; unsigned char new_min; unsigned char new_hrs; unsigned char new_read; total_secs = 0x00; temp_read = 0x00; new_read = 0x00;
do { if((thinking == 1) && (easy == 0) && (medium == 0) && (hard == 0)) { yellow_led = ON; green_led = OFF; amber_led = OFF; red_led = OFF; temp_read = 0x08; }
else if((thinking == 1) && (easy == 1) && (medium == 0) && (hard == 0)) { yellow_led = ON; green_led = ON; amber_led = OFF; red_led = OFF; temp_read = 0x0C; }
else if((thinking == 1) && (easy == 1) && (medium == 1) && (hard == 0)) { yellow_led = ON; green_led = ON; amber_led = ON; red_led = OFF; temp_read = 0x0E; }
else if((thinking == 1) && (easy == 1) && (medium == 1) && (hard == 1)) { yellow_led = ON; green_led = ON; amber_led = ON; red_led = ON; temp_read = 0x0F;
}
else { yellow_led = OFF; green_led = OFF; amber_led = OFF; red_led = OFF; temp_read = 0x00; }
while (temp_read == temp_read);
external_write(temp_read);
return; }
I'm using a function to write to external memory that puts the byte on the port 1 byte at a time. I don't understand how to write to this external writing function. what are you talking about, you are coding in 'C' so why would you have "a function to write to external memory".
Erik
Because he is manually driving the ports to write to external memory instead of having the processor directly access the memory using xdata accesses. Everything is possible, even if most people would prefer the processor to do the work.
that he has never seen ths XDATA keyword?
Everything is possible try striking a match on a bar of soap :)
I have to write the function to get the timing right for the type of external memory chip i'm using. So will I need to split up the data into bytes some way?
So will I need to split up the data into bytes some way? I do not understand what you mean you can, of course, only read or write to one memory address (one byte for 8-bit wide memory) at a time.
Why be vague, what type. But Yes you take your data break it up into bytes. Write one, inc the address and repeat until done.
How to break up the data there are several ways. shifts, pointers, and unions are some.