Author Topic: Arduino  (Read 1075 times)

0 Members and 1 Guest are viewing this topic.

Offline Balakumaran SelvarajiTopic starter

  • Contributor
  • Posts: 26
  • Country: in
Arduino
« on: December 25, 2017, 10:31:58 am »
Hello,
    I am using Arduino to program my EEPROM for the Output of my 8-bit breadboard computer. This was the code which I was running ::

#define SHIFT_DATA 2
#define SHIFT_CLK 3
#define SHIFT_LATCH 4
#define EEPROM_D0 5
#define EEPROM_D7 12

void setAddress(int address, bool outputEnable)
{
  shiftOut(SHIFT_DATA, SHIFT_CLK, MSBFIRST, (address >> 8) | (outputEnable ? 0x00 : 0x80));
  shiftOut(SHIFT_DATA, SHIFT_CLK, MSBFIRST, address);
  digitalWrite(SHIFT_LATCH, LOW);
  digitalWrite(SHIFT_LATCH, HIGH);
  digitalWrite(SHIFT_LATCH, LOW);


byte readEEPROM(int address){
  setAddress(address, /*OutputEmable*/ true);
  byte data = 0;
  for(int pin = EEPROM_D7; pin >= EEPROM_D0; pin -= 1){
      data = (data << 1) + digitalRead(pin);
    }
    return data;
  }
void setup() {
  // put your setup code here, to run once:
  pinMode(SHIFT_DATA,OUTPUT);
  pinMode(SHIFT_CLK,OUTPUT);
  pinMode(SHIFT_LATCH,OUTPUT);
 
  Serial.begin(57600);
  for (int base = 0; base <=255; base += 16){
    byte data[16];
    for(int offset = 0; offset <=15; offset +=1){
      data[offset] = readEEPROM(base + offset);
      }
      char buf[80];
      sprintf(buf, "%03x: %02x %02x %02x %02x %02x %02x %02x %02x     %02x %02x %02x %02x %02x %02x %02x %02x",
      base, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10],
      data[11], data[12], data[13], data[14], data[15]);

      Serial.println(buf);
   }
}

void loop() {
  // put your main code here, to run repeatedly:

}


Now, I ideally this must give me what is there in the contents of the EEPROM in the Serial Monitor. But, when I look at it - I get crazy kind of Fonts...

For Example : (This was in My EEPROM btw)

????)a?O"??!5???CC?BB!B?BCD??B??!F??!B??&?C??Fic?!
???HCBC???B!??!
?BÆ@??K??B!B?F!!!¡DB???B!N?!?E
B)#F?"??B?=!??C?"?

 

Offline HecticZA

  • Contributor
  • Posts: 41
  • Country: za
Re: Arduino
« Reply #1 on: December 25, 2017, 10:41:37 am »
Hello,
    I am using Arduino to program my EEPROM for the Output of my 8-bit breadboard computer. This was the code which I was running ::

#define SHIFT_DATA 2
#define SHIFT_CLK 3
#define SHIFT_LATCH 4
#define EEPROM_D0 5
#define EEPROM_D7 12

void setAddress(int address, bool outputEnable)
{
  shiftOut(SHIFT_DATA, SHIFT_CLK, MSBFIRST, (address >> 8) | (outputEnable ? 0x00 : 0x80));
  shiftOut(SHIFT_DATA, SHIFT_CLK, MSBFIRST, address);
  digitalWrite(SHIFT_LATCH, LOW);
  digitalWrite(SHIFT_LATCH, HIGH);
  digitalWrite(SHIFT_LATCH, LOW);


byte readEEPROM(int address){
  setAddress(address, /*OutputEmable*/ true);
  byte data = 0;
  for(int pin = EEPROM_D7; pin >= EEPROM_D0; pin -= 1){
      data = (data << 1) + digitalRead(pin);
    }
    return data;
  }
void setup() {
  // put your setup code here, to run once:
  pinMode(SHIFT_DATA,OUTPUT);
  pinMode(SHIFT_CLK,OUTPUT);
  pinMode(SHIFT_LATCH,OUTPUT);
 
  Serial.begin(57600);
  for (int base = 0; base <=255; base += 16){
    byte data[16];
    for(int offset = 0; offset <=15; offset +=1){
      data[offset] = readEEPROM(base + offset);
      }
      char buf[80];
      sprintf(buf, "%03x: %02x %02x %02x %02x %02x %02x %02x %02x     %02x %02x %02x %02x %02x %02x %02x %02x",
      base, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10],
      data[11], data[12], data[13], data[14], data[15]);

      Serial.println(buf);
   }
}

void loop() {
  // put your main code here, to run repeatedly:

}


Now, I ideally this must give me what is there in the contents of the EEPROM in the Serial Monitor. But, when I look at it - I get crazy kind of Fonts...

For Example : (This was in My EEPROM btw)

????)a?O"??!5???CC?BB!B?BCD??B??!F??!B??&?C??Fic?!
???HCBC???B!??!
?BÆ@??K??B!B?F!!!¡DB???B!N?!?E
B)#F?"??B?=!??C?"?
Did you copy and paste the code from a website?

Sent from my SM-N950F using Tapatalk

 

Offline Balakumaran SelvarajiTopic starter

  • Contributor
  • Posts: 26
  • Country: in
Re: Arduino
« Reply #2 on: December 25, 2017, 10:45:40 am »
Nah man. I just started programming this stuff to check what is in my EEPROM
 

Offline Nusa

  • Super Contributor
  • ***
  • Posts: 2416
  • Country: us
Re: Arduino
« Reply #3 on: December 25, 2017, 10:46:39 am »
My first thought is baud rate mismatch. Is your serial monitor also at 57600?
Can you get a "hello world" program to work?

Serial.begin(57600);
Serial.print("hello world");
 
The following users thanked this post: Balakumaran Selvaraji

Offline Balakumaran SelvarajiTopic starter

  • Contributor
  • Posts: 26
  • Country: in
Re: Arduino
« Reply #4 on: December 25, 2017, 10:49:22 am »
Thank You Nusa.
      I tried doing
      Serial.begin(19200);
     and setting the baud to 19200 baud.

So, now it is working properly and I am getting the desired output from my eeprom.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf