>Hi: >I am using a 16F84 to read serial data and want to store it in >sequential files (using FSR). Rather than hard code the starting >file address I would like a way to make it the next available >address after the last CBLOCK/ENDC assignment. > >If this is not possible, can I assign the data storage starting >at file 00 and somehow tell the assembler where to start the >first CBLOCK? > Hi Brooke, I just finished doing this on a project (actually probably the same thing you are trying to do - read serial data and store it in a buffer for later reading). I don't use CBLOCK/ENDC, but the code below is pretty efficient and easy to maintain (without worrying about loosing addresses). I created two pointer variables, "Next" and "ShadowFSR" (I know the names aren't very descriptive, but it was a evolutionary program) for the Next location to store the incoming data and where to look for the data, respectively. ie, the declaration is: Char EQU 0x00C ; Serial Character Read in Next EQU 0x00D ; Just put in addresses where ever ShadowFSR EQU 0x00E BufferStart EQU 0x00F ; Setup a 16 Byte Circular Buffer BufferEnd EQU 0x01E Then, in the Interrupt Handler, when I have and verified the read in "Char": incf Next, w ; Get the Index to the Next Store Location addlw 0 - ( BufferEnd + 1 ) ; See if we were at the End of the Buffer btfsc STATUS, C ; If Carry Set, then Yes, Reset to Start addlw BufferStart - ( BufferEnd + 1 ) addlw BufferEnd + 1 ; "w" is now the Correct, Updated Location movwf Next ; Store the Updated Location movwf FSR ; Point to the location in the Buffer movf Char, w ; Now, Store the Character at the Location movwf INDF Doing it this way means you have to save the FSR (because you are going to be using it in the mainline). In the Mainline, to poll on getting the character and putting it in "w" for use: Loop ; Loop Here waiting for character movf Next, w ; See if Next has changed (a character Rx'd) subwf ShadowFSR, w btfsc STATUS, Z ; If they're not the same: Character Rx'd goto Loop incf ShadowFSR, w ; Now, Increment the Pointer to the Code addlw 0 - ( BufferEnd + 1 ) ; - Note, it's the same code as above btfsc STATUS, C addlw BufferStart - ( BufferEnd + 1 ) addlw BufferEnd + 1 movwf ShadowFSR movwf FSR movf INDF, w ; Get the Character and Process . : goto Loop ; Finished, Wait for the Next Character >PS. has anyone got AN555 to work on a 1684? The code above, and the 9600 bps Serial Read/Write routines that go with them are what I did after reading AN555 - I didn't try to implement them. My read routine is Interrupt Based (I used RB0/INT). A couple of things on using the 16C84 for Serial/RS-232 Communication. If you use RB0/INT for receive, you might want to plan on using RA1 for Transmit; this way you can use RA0 for the 8th bit of the RB0. If you are going to echo back the characters sent, you might want to use a different PIC; when you are XMitting characters, there may be a problem with a character being received at the same time. This caused me a lot of problems with CR/LF. Good Luck! Today, the commercial sector is advancing computer and communication technology at a breakneck pace. In 1992, optical fiber was being installed within the continental U.S. at rates approaching the speed of sound (if computed as total miles of fiber divided by the number of seconds in the year). Aviation Week and Space Technology, October 28, 1996