----- Original Message ----- From: "Jamey Schroeder" To: Sent: Monday, September 04, 2000 1:23 PM Subject: [PIC] PIC16F84 -Data Memory Question, reading/erasing > I've been experimenting with the pic for about a month or so. Currently I > am trying to set up serial communications with a pc at 9600bps. I have been > successful in sending more the one byte of data to the pic and having it > store the data into eeprom. I'm not happy with the way I had to write the > code. The way I have it set up now is when you send the first byte of data > to the pic it puts it into a register for use as a counter. The first byte > tells the pic how many more bytes are coming. When it recieves the > following bytes it stores them into memory. I had to use several goto and > subroutines in order to get this to work, I have a seperate routine for > every byte location. I have it set up so it can recieve a maximum of 8 > bytes. I would like to have one routine for the whole job. > > I was wondering if there is a way to have a loop where the data location to > store the data is incremented so that I can shorten my code. > > I guess for starters what I would want to do is clear an area of my Data > Memory. I want to specify the number of bytes to clear and where to start. > If I had a loop to do that I could probably use the same concept for storing > data into memory. > > Does anyone have any ideas on this? How about if you use something like this: Store first byte as bytecount variable Store last used memory location as lastmem variable DoItAgain: get next byte store it in (lastmem - bytecount)+1 decfsz bytecount (decrement bytecount and skip next command if zero) goto DoItAgain Goto Finished . -- http://www.piclist.com hint: PICList Posts must start with ONE topic: "[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's