0 Replies Latest reply on Mar 5, 2011 12:47 AM by qmor

    28F640j3 programming

    qmor
      Hello.
      I've got GR-MCC-C board with 28F640j3 flash memory on it and I have a couple of questions about writing bytes to flash.
      For example, I want to program byte at adress 0x0 with value 0xA, here's the code which is _not_ working:
      unsigned char* _ptr = 0x0;
      *_ptr = 0x10; // command code: write byte
      *_ptr = 0xA; // data to write
      *_ptr = 0xFF; // switching to 'read array' mode
      I figured out, that it works okay if I put a little delay between the commands, so my code will look like this:
      unsigned char* _ptr = 0x0;
      *_ptr = 0x10; // command code: write byte
      usleep(100);
      *_ptr = 0xA; // data to write
      usleep(100);
      *_ptr = 0xFF; // switching to 'read array' mode
      Now I get what I want: 0xA at 0x0. Here comes the question - since it seems that device needs time to process each command, how can I check, that device is ready to receive next command?
      How long should delay be?
      I had a suggestion that status register could help me answering it (SR7 should tell me if WSM is ready). So I wrote the sequence of commands:
      unsigned char* _sr = 0x100; // datasheet says that you can use any valid adress within the device for this operation
      unsigned char csr;
      *_sr = 0x70; // command code: read status register
      csr = *_sr; // reading status register
      *_sr = 0xFF; // back to 'read array'
      printf("Status register: %x\n",csr);
      This code prints either 80 or 70 (command code or real status?), and I couldn't find dependence between it and possible status.
      I've just started using the board so I would really appreciate if You tell me what I'm doing wrong and how can I solve this couple of problems.