Hello everybody, i'm busy with a school endassignment at a company. I need to build a datalogger and i want to use a 8mbit atmel dataflash memory for storage. = I'm using a 16F877a pic mcu and the spi bus to acces it. I'm using the ccs compiler. To test it i'm doing the following: put a value in buffer1 > re= ad it back > put buffer1 to a page > read the page back to buffer2 > reading the value from buffer2 > also read the value direct from the page. Each t= ime i use printf to output the results to my pc to verify if everything went right. The strange thing is that i can succesfully store my value in any page i want, and read it back. But this only works when the byte address (there are 264 bytes in a buffer and a page) is 0 to 18 and 256 to 265! Every other byte address value leads to reading back "255" :-( ........ I hope somebody can help me because it is a very strange problem and i've already spent a day finding it. Thanks a lot! Vincent Blok The Netherlands Here are some pieces of the code i use to perform the reads and writes: (it also doesn't work if i hardcode the adresses in stead of using variab= le names) void df_write_b1(int8 value, int16 b_addr) { int8 b_addr_l, b_addr_h; b_addr_l =3D make8(b_addr, 0); b_addr_h =3D make8(b_addr, 1); output_low(pin_b4); =20 spi_write(0x84); =20 spi_write(0x00); =20 #asm movf 0x13,w #endasm //these seem to be necessary, i think it is= a bug in ccs spi_write(b_addr_h); =20 #asm movf 0x13,w #endasm spi_write(b_addr_l); =20 #asm movf 0x13,w #endasm spi_write(value); =20 output_high(pin_b4); =20 } int8 df_read_b1(int16 b_addr) { int8 rxspi, b_addr_l, b_addr_h; b_addr_l =3D make8(b_addr, 0); b_addr_h =3D make8(b_addr, 1); output_low(pin_b4); =20 spi_write(0xD4); =20 spi_write(0x00); =20 #asm movf 0x13,w #endasm spi_write(b_addr_h); =20 #asm movf 0x13,w #endasm spi_write(b_addr_l); =20 spi_write(0x00); =20 rxspi=3Dspi_read(0); =20 output_high(pin_b4); =20 return rxspi; =20 } int8 df_read_b2(int16 b_addr) { int8 rxspi, b_addr_l, b_addr_h; b_addr_l =3D make8(b_addr, 0); b_addr_h =3D make8(b_addr, 1); output_low(pin_b4); =20 spi_write(0xD6); =20 spi_write(0x00); =20 #asm movf 0x13,w #endasm spi_write(b_addr_h); =20 #asm movf 0x13,w #endasm spi_write(b_addr_l); =20 spi_write(0x00); =20 rxspi=3Dspi_read(0); =20 output_high(pin_b4); =20 return rxspi; =20 } void df_b1_to_page_e(int16 p_addr) { int8 p_addr_l, p_addr_h; p_addr =3D p_addr << 1; p_addr_l =3D make8(p_addr, 0); p_addr_h =3D make8(p_addr, 1); output_low(pin_b4); spi_write(0x83); #asm movf 0x13,w #endasm spi_write(p_addr_h); #asm movf 0x13,w #endasm spi_write(p_addr_l); spi_write(0x00); output_high(pin_b4); delay_ms(23); } void df_page_to_b2(int16 p_addr) { int8 p_addr_l, p_addr_h; p_addr =3D p_addr << 1; p_addr_l =3D make8(p_addr, 0); p_addr_h =3D make8(p_addr, 1); output_low(pin_b4); spi_write(0x55); #asm movf 0x13,w #endasm spi_write(p_addr_h); #asm movf 0x13,w #endasm spi_write(p_addr_l); spi_write(0x00); output_high(pin_b4); delay_us(310); } int8 df_page_read(int16 p_addr, int16 b_addr) { int8 rxspi, p_addr_l, p_addr_h, b_addr_l, b_addr_h; p_addr =3D p_addr << 1; p_addr_l =3D make8(p_addr, 0); p_addr_h =3D make8(p_addr, 1); b_addr_l =3D make8(b_addr, 0); b_addr_h =3D make8(b_addr, 1); output_low(pin_b4); =20 spi_write(0xD2); =20 #asm movf 0x13,w #endasm spi_write(p_addr_h); =20 #asm movf 0x13,w #endasm spi_write(p_addr_l | b_addr_h); =20 #asm movf 0x13,w #endasm spi_write(b_addr_l); =20 spi_write(0x00); =20 spi_write(0x00); =20 spi_write(0x00); =20 spi_write(0x00); =20 rxspi =3D spi_read(0); =20 output_high(pin_b4); =20 return rxspi; =20 } Deze e-mail en de inhoud daarvan is vertrouwelijk. Indien dit bericht nie= t voor u bestemd is, verzoeken wij u deze e-mail direct aan ons te retourne= ren en daarna te vernietigen. In dit geval is het ook niet toegestaan deze e-mail en de inhoud daarvan te gebruiken, kopi=EBren of openbaar te maken= aan derden. Holland Railconsult B.V. sluit elke aansprakelijkheid uit in verb= and met het niet juist, onvolledig of niet tijdig overkomen van de informatie= in deze e-mail. This e-mail and its contents are confidential and may be legally privileg= ed. If this e-mail is not intended for you, please contact us immediately by reply e-mail and destroy the e-mail. In this case, please do neither use, nor copy or disclose the e-mail and its contents to anyone. Holland Railconsult B.V. is neither liable for the proper and complete transmissi= on of the information in this e-mail nor for any delay in its receipt. -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body