Hi
I am trying to read data from a Prom by waiting for the address selector to switch to 0x00.
Then read the data and wait for address 0x01.
In my code the while loop never move on to the next line.
I even hard wire the address inputs on my arduino to ground to simulate the first 0x00.
The Serial.print only prints a never ending loop of zeros but does not exit the while loop.
Something wrong with my while loop.
uint8_t randNumber = 0;
uint8_t data = 0;
const unsigned int numReadings = 8;
unsigned int myArray[numReadings];
int PE = 17;//A3
int ME = 18;//A4
int WORD1 = 0;
int WORD2 = 0;
int WORD3 = 0;
int WORD4 = 0;
int WORD5 = 0;
int WORD6 = 0;
int WORD7 = 0;
int WORD8 = 0;
int val = 0;
int counter = 0;
int a = 30;
int CHANNEL = 0X05;//anything but zero
long startUs;
long endUs;
long elapsed;
void printdata()
{
Serial.println(WORD1);
Serial.println(WORD2);
Serial.println(WORD3);
Serial.println(WORD4);
Serial.println(WORD5);
Serial.println(WORD6);
Serial.println(WORD7);
Serial.println(WORD8);
}
void setup()
{
pinMode (PE, OUTPUT);
pinMode (ME, INPUT);
pinMode (14, INPUT);
pinMode (15, INPUT);
pinMode (16, INPUT);
pinMode (8, INPUT);
pinMode (9, INPUT);
pinMode (10, INPUT);
pinMode (11, INPUT);
Serial.begin (9600);
//Serial.println("NJ8820");
//delay(1000);
}
void loop()
{
while (digitalRead(18) == HIGH) //Memory Enable - wait for low pulse
{
}
delayMicroseconds(52);//(13uS X 4) clock cycles
while ( CHANNEL != 0X00)
{
byte CHANNEL = PINC;//
CHANNEL = CHANNEL & B00000111;//MASK OFF UPPER BITS
Serial.println(CHANNEL);
}
byte WORD1 = PINB;//
WORD1 = WORD1 & B00001111;//mask off upper 4 bits
//----------------------
while ( CHANNEL != 0X01)
{
byte CHANNEL = PINC;//
CHANNEL = CHANNEL & B00000111;//MASK OFF UPPER BITS
}
byte WORD2 = PINB;//
WORD2 = WORD2 & B00001111;//mask off upper 4 bits
//----------------------
while ( CHANNEL != 0X02)
{
byte CHANNEL = PINC;//
CHANNEL = CHANNEL & B00000111;//MASK OFF UPPER BITS
}
byte WORD3 = PINB;//
WORD3 = WORD3 & B00001111;//mask off upper 4 bits
//----------------------
while ( CHANNEL != 0X03)
{
byte CHANNEL = PINC;//
CHANNEL = CHANNEL & B00000111;//MASK OFF UPPER BITS
}
byte WORD4 = PINB;//
WORD4 = WORD4 & B00001111;//mask off upper 4 bits
//----------------------
while ( CHANNEL != 0X04)
{
byte CHANNEL = PINC;//
CHANNEL = CHANNEL & B00000111;//MASK OFF UPPER BITS
}
byte WORD5 = PINB;//
WORD5 = WORD5 & B00001111;//mask off upper 4 bits
//----------------------
while ( CHANNEL != 0X05)
{
byte CHANNEL = PINC;//
CHANNEL = CHANNEL & B00000111;//MASK OFF UPPER BITS
}
byte WORD6 = PINB;//
WORD6 = WORD6 & B00001111;//mask off upper 4 bits
//----------------------
while ( CHANNEL != 0X06)
{
byte CHANNEL = PINC;//
CHANNEL = CHANNEL & B00000111;//MASK OFF UPPER BITS
}
byte WORD7 = PINB;//
WORD7 = WORD7 & B00001111;//mask off upper 4 bits
//----------------------
while ( CHANNEL != 0X07)
{
byte CHANNEL = PINC;//
CHANNEL = CHANNEL & B00000111;//MASK OFF UPPER BITS
}
byte WORD8 = PINB;//
WORD8 = WORD8 & B00001111;//mask off upper 4 bits
//------------------------------
Serial.println(WORD1);
Serial.println(WORD2);
Serial.println(WORD3);
Serial.println(WORD4);
Serial.println(WORD5);
Serial.println(WORD6);
Serial.println(WORD7);
Serial.println(WORD8);
Serial.println("Done");
while (1)
{
}
}
Thanks.