I'm looking for a litle help with a project I'm building.
I repair/setup industrial CNC equipment for a living. There are times I need to check the timing of signals on this equipment. The frequency of me doing this does not warrant purchasing a commercial data logger.
I am building a simple one, using a 4 x 20 LCD display to show the data. I would like to display up to 5 pages of info on the LCD. I don't need to save the data in case of power loss, but if EEPROM is the best way let me know. I'm using a PIC 16f876a.
What I want to do is sample PORTA at pre determined intervals (from .1 to .01 seconds depending on the value in TMR1). I then would like to save PORTA and put it in file1. On the next read I want the value to go into file2, etc., up to file100 Once file100 has been reached the program will loop back to file1. This will continue until a button is pressed or and external trigger is seen. I will then display the info on the LCD.
What I'm looking for is an elegant way to put the info into one file and then incrementing to the next file on the next read. I'm also looking for a way of reading the files in succesion ( to be displayed on the LCD).
Maybe I'm missing something painfully obvious. I'm not a total noob but some days I feel like it.
I'm not looking for someone to write the code but rather a nudge in the best direction.
I'm using assembly. Any suggestions would be appreciated.
One suggestion would be to not use assembly, using a higher level language makes writing code much quicker.
That aside, to write to a file in the manner you described, you'd use indirect addressing. First you load FSR with the address of the file, then read/write to INDF (which now contains the addressed file contents). If you can use bank 2 or 3, there is 100 bytes of contiguous memory which will make things easier, otherwise you'll have to check each access whether you're in the right bank.
I started working with indirect addressing as suggested by dougy83. Everything appears to work except when I write info into memory address 170h. When I write to this address it also writes to 70h, f0, and 1f0. What am I doing wrong?
You're not doing anything wrong. The top 16 bytes of each bank are shared between all banks (see picture from datasheet). If this is a problem for you, you will have to incorporate bank switching to access your 100-byte buffer (or just use 96 bytes in your buffer).