Well, most of the program is up and running, I can draw diagonal lines across the CRT by ramping both DACs from o to 255, now the next step is writing and reading the eeprom. I looked in the data sheets for the memory map but EEprom appears to be 0 to 255 address (no offset).
Any way here is a snippit of the code with the writes and my attempts to read and display on my LCD. All I get is 255 (0xff) from address 0 to 255 (not entirly, see below). The code here is shown only the part I need help on, it's getting too long to post the whole thing.
Any help on EEPROM and I think I will have this project under control.
'
'First, setup eeprom memory with data
' 16 bytes of Data per line, 16 lines for 256 bytes, can go
; to 256 bytes with PIC16F886 ChipFamily
' 'First byte Vert position, 2nd byte Horz position
EPWRITE 0, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
EPWRITE 16, 9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16
EPWRITE 32, 17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24
EPWRITE 48, 25,25,26,26,27,27,28,28,29,29,30,30,31,31,32,32
EPWRITE 64, 33,33,34,34,35,35,36,36,37,37,38,38,39,39,40,40
EPWRITE 80, 41,41,42,42,43,43,44,44,45,45,46,46,47,47,48,48
'
;----------------------------------------------------------------
; Read the eeprom bytes for test
testlp=0 ;intialize test loop
Do Forever
for testlp=0 to 255
EPRead testlp, AtoD_Value
hserprint AtoD_Value ;write value to LCD for testing
wait 500 ms
next testlp
clear_screen ;done all 256 bytes
Loop
;
Well, additional checking showed the read is apparently working but something wrong with the writes, apparently I cannot delinate byte writes with just a comma. Found that location 0 had a one, location 16 had a nine, location 32 had a 17 and so forth, but all other locations had 255.
So apparently I can only write one byte per EPWRITE staement ??????? If so this is going to be clumsy.
Guess I will have to structure an aray and EPWRITE byte by byte from an array.
Last edit: Paul Haug 2017-03-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Pointers should be implemented in the near future to allow multiple bytes with EPWRITE and others. In the mean time remember that GCB supports arrays. So first put the data in an array, then wrrite to EEPROM in a loop. Like this (Untested)
Dim EEData(16) ' // 16 Byte Array
Dim EEAddr as Byte
Dim ii as Byte '// Array Pointer
EEData = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 '// Put 16 bytes data in array
WriteData 0
Sub WriteData (in EEAddr)
For ii = 1 to EEData(0) '// index 0 is numbytes in Array
EPWRITE EEAddr, EEdata(ii)
EEaddr++ '// Increment Address
Next
End Sub ,
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Remember after your code is tested and debugged and the EEPROM is loaded with Data , you must add a command line switch to IPECMD.exe to prevent the EEPROM from being erased upon subsequent programing.. The switch is -Z.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As Evan suggested, it is probably a better option to use a lookup table. A lookup table is easier to set up, easier to read, and can be read more than 10 times faster (literally) than EEPROM.
A single EEPROM read takes about 3.8 microseconds. A single Table read takes about 320 nano seconds. (16F@32Mhz)
Below is how I might Use/Test a table given the source code you provided. I used a PIC16F18855 so you will need to adapt for whatever chip you end up using.
Note: You do not need the PPS stuff in this Code. PPS is for PIC chips with Peripheral Pin Select capabilities.
;-----Configuration#chip 16f18855,32#Config FEXTOSC_OFF, RSTOSC_HFINT32#Config WRT_OFF, CPD_ON, MCLRE_OFF#Option Explicit#startup INITPPS, 85''' Define I2C settings #define hi2c_BAUD_RATE 400 #define hi2c_Clock PORTC.3 #define hi2c_Data PORTC.4 Dir HI2C_DATA in Dir HI2C_CLOCK in HI2CMode Master '''SetupLCD#define LCD_IO 10#define LCD_I2C_Address_1 0x7E#define LCD_SPEED SLOW#define LCD_Backlight_On_State 1#define LCD_Backlight_Off_State 0''' variables Dim TableData as Byte Dim ii as Byte Dim location as byte Dim numbytes as byte '''Tablelocation"0"alwaysholdsthenumberofbytesinthetable''' For example: Loc "0" in the table below will hold a byte value of 80 Table MyTable as Byte '// 80 Bytes 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48End Table'---- Main Program Begins Here -----CLS '// Clear LCD DisplayDo Locate 0,0 '// Start of LCD Line 0 Read_MyTable (1,4) '// read 4 bytes starting at location 1 Locate 1,0 '// Start of LCD Line 1 Read_MyTable(17,4) '// read 4 bytes starting at location 17 Locate 2,0 '// Start of LCD Line 2 Read_MyTable(49,4) '// read 4 bytes starting at location 49 Locate 3,0 '// Start of LCD Line 3 Read_MyTable(65,4) '// read 4 bytes starting at location 65 Wait 4 s CLS Wait 1 sLoopENDSub Read_MyTable(location, numbytes) for ii = location to (location + numbytes -1) ReadTable MyTable, ii, TableData Print tableData : LCDSPACE 1 nextEnd SubSub InitPPSUNLOCKPPS 'Module: MSSP1 RC3PPS = 0x0014 'SCL1 > RC3 SSP1CLKPPS = 0x0013 'RC3 > SCL1 (bi-directional) RC4PPS = 0x0015 'SDA1 > RC4 SSP1DATPPS = 0x0014 'RC4 > SDA1 (bi-directional)LOCKPPSEnd Sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks guys, I did setup a lookup table and have it running. I had been thinking that the EEPROM was just sort of redundit and not useful in this application, since the data is always retained within the code itself, so the extra 256 bytes of EEPROM was not very useful in this application. I had not remembered EEprom speed, might be important for this application (CRT Updatei).
I can now draw simple shapes on the CRT but have a long way to go.
Again, Thanks.
Paul
Last edit: Paul Haug 2017-03-15
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well, most of the program is up and running, I can draw diagonal lines across the CRT by ramping both DACs from o to 255, now the next step is writing and reading the eeprom. I looked in the data sheets for the memory map but EEprom appears to be 0 to 255 address (no offset).
Any way here is a snippit of the code with the writes and my attempts to read and display on my LCD. All I get is 255 (0xff) from address 0 to 255 (not entirly, see below). The code here is shown only the part I need help on, it's getting too long to post the whole thing.
Any help on EEPROM and I think I will have this project under control.
'
'First, setup eeprom memory with data
' 16 bytes of Data per line, 16 lines for 256 bytes, can go
; to 256 bytes with PIC16F886 ChipFamily
' 'First byte Vert position, 2nd byte Horz position
EPWRITE 0, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
EPWRITE 16, 9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16
EPWRITE 32, 17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24
EPWRITE 48, 25,25,26,26,27,27,28,28,29,29,30,30,31,31,32,32
EPWRITE 64, 33,33,34,34,35,35,36,36,37,37,38,38,39,39,40,40
EPWRITE 80, 41,41,42,42,43,43,44,44,45,45,46,46,47,47,48,48
'
;----------------------------------------------------------------
; Read the eeprom bytes for test
testlp=0 ;intialize test loop
;
Well, additional checking showed the read is apparently working but something wrong with the writes, apparently I cannot delinate byte writes with just a comma. Found that location 0 had a one, location 16 had a nine, location 32 had a 17 and so forth, but all other locations had 255.
So apparently I can only write one byte per EPWRITE staement ??????? If so this is going to be clumsy.
Guess I will have to structure an aray and EPWRITE byte by byte from an array.
Last edit: Paul Haug 2017-03-14
Use a table. Look at the Help with the write to EEPROM option.
Pointers should be implemented in the near future to allow multiple bytes with EPWRITE and others. In the mean time remember that GCB supports arrays. So first put the data in an array, then wrrite to EEPROM in a loop. Like this (Untested)
Dim EEData(16) ' // 16 Byte Array
Dim EEAddr as Byte
Dim ii as Byte '// Array Pointer
EEData = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 '// Put 16 bytes data in array
WriteData 0
EEdata = 9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16
WriteData 16
EEdata = 17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24
WriteData 32
EEdata = 25,25,26,26,27,27,28,28,29,29,30,30,31,31,32,32
WriteData 48
EEdata = 33,33,34,34,35,35,36,36,37,37,38,38,39,39,40,40
WriteData 64
EEdata = 41,41,42,42,43,43,44,44,45,45,46,46,47,47,48,48
WriteData 80
Sub WriteData (in EEAddr)
For ii = 1 to EEData(0) '// index 0 is numbytes in Array
EPWRITE EEAddr, EEdata(ii)
EEaddr++ '// Increment Address
Next
End Sub ,
See http://gcbasic.sourceforge.net/help/_lookup_tables.html at the bottom of the page
Remember after your code is tested and debugged and the EEPROM is loaded with Data , you must add a command line switch to IPECMD.exe to prevent the EEPROM from being erased upon subsequent programing.. The switch is -Z.
Paul,
As Evan suggested, it is probably a better option to use a lookup table. A lookup table is easier to set up, easier to read, and can be read more than 10 times faster (literally) than EEPROM.
A single EEPROM read takes about 3.8 microseconds. A single Table read takes about 320 nano seconds. (16F@32Mhz)
Below is how I might Use/Test a table given the source code you provided. I used a PIC16F18855 so you will need to adapt for whatever chip you end up using.
Note: You do not need the PPS stuff in this Code. PPS is for PIC chips with Peripheral Pin Select capabilities.
Thanks guys, I did setup a lookup table and have it running. I had been thinking that the EEPROM was just sort of redundit and not useful in this application, since the data is always retained within the code itself, so the extra 256 bytes of EEPROM was not very useful in this application. I had not remembered EEprom speed, might be important for this application (CRT Updatei).
I can now draw simple shapes on the CRT but have a long way to go.
Again, Thanks.
Paul
Last edit: Paul Haug 2017-03-15