Need help programming W29C020 Flash BIOS chip using 16F819

Status
Not open for further replies.

zanor

Member level 4
Joined
Feb 17, 2006
Messages
79
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Norway
Activity points
2,039
Hi!

I'm trying to program this chip using PIC16F819. I have managed to read it but not erase/program or even getting right ID. I'm using three 74HC595 for adressing and PORTB for data #CE is wired directly to ground.
Datasheet for W29C020

ANY help/comments/suggestions would be great!!


I know there are severeal other programmers out on the net with ready pcb drawings and everything, but I want to do it the hard way. Make my own

Here is my code so far (using mikroC):
Code:
#define bit_set(var,bitno) ((var) |= 1 << (bitno))
#define bit_clr(var,bitno) ((var) &= ~(1 << (bitno)))

int     DATA;
int     x, y;

void clock() {
  bit_set(PORTA, 3);
  bit_clr(PORTA, 3);
}

void latch() {
  bit_set(PORTA, 4);
  bit_clr(PORTA, 4);
}

void send_adr(unsigned long int ADR){
  clock();
  for(x=0;x<24;x++) {
    if((ADR >> x) & 0x1) {
      bit_set(PORTA, 2);
    }
    clock();
    bit_clr(PORTA, 2);
  }
  latch();
}

void read_byte(unsigned long int tmp) {
  TRISB = 0xFF;

  send_adr(tmp);

  bit_clr(PORTA, 0);
  Delay_ms(1);

  data = PORTB;
  bit_set(PORTA, 0);
}
void write_byte(unsigned long int tmp, int tmp2) {
  TRISB = 0x00;

  send_adr(0x5555);
  bit_clr(PORTA, 1);
  PORTB = 0xAA;
  bit_set(PORTA, 1);

  send_adr(0x2AAA);
  bit_clr(PORTA, 1);
  PORTB = 0x55;
  bit_set(PORTA, 1);
  
  send_adr(0x5555);
  bit_clr(PORTA, 1);
  PORTB = 0xA0;
  bit_set(PORTA, 1);

  send_adr(tmp);
  bit_clr(PORTA, 1);
  PORTB = tmp2;
  bit_set(PORTA, 1);

  read_byte(tmp);
  while((DATA != tmp2) && ((DATA & 0x20) == 0)) {
    read_byte(tmp);
  }
  
  read_byte(tmp);
  if(DATA == tmp2)
    Soft_Uart_Write(0xFF);
  else
    Soft_Uart_Write(0x44);
  
}

void erase_chip() {
  TRISB = 0x00;

  send_adr(0x5555);
  PORTB = 0xAA;
  bit_clr(PORTA, 1);
  bit_set(PORTA, 1);

  send_adr(0x2AAA);
  PORTB = 0x55;
  bit_clr(PORTA, 1);
  bit_set(PORTA, 1);

  send_adr(0x5555);
  PORTB = 0x80;
  bit_clr(PORTA, 1);
  bit_set(PORTA, 1);
  
  send_adr(0x5555);
  PORTB = 0xAA;
  bit_clr(PORTA, 1);
  bit_set(PORTA, 1);

  send_adr(0x2AAA);
  PORTB = 0x55;
  bit_clr(PORTA, 1);
  bit_set(PORTA, 1);

  send_adr(0x5555);
  PORTB = 0x10;
  bit_clr(PORTA, 1);
  bit_set(PORTA, 1);

  Delay_ms(50);
  
}


void main(){
  OSCCON = 0xFF;
  ADCON1 = 0x06;
  TRISA = 0b00000000;
  TRISB = 0b11111111;
  PORTA = 0x03;
  PORTB = 0x00;
  


  Soft_Uart_Init(PORTA, 6, 7, 9600, 0);


  Delay_ms(1000);
  Soft_Uart_Write(0x01);

  read_byte(0x145);
  Soft_Uart_Write(data);
  
  //write_byte(0x145, 0x23);
  erase_chip();

  read_byte(0x145);
  Soft_Uart_Write(data);


}
 

Hey! There must be anyone on this froum that have the knowledge I need.... :|
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…