Nog steeds aan het stoeien met een PIC en de EEPROM. Nu echter de simulatie. in mijn code heb ik:



......
           banksel EEADR
           MOVLW   low TABLEREF
           MOVWF   EEADR
           banksel DCOffs_CH1
                
;Flags QDR1_2 and QDR2_3 determin which value to use for interpolation, 
;CH1 if QDR1_2 EXOR QDR2_3 = 1,
;CH2 if QDR1_2 EXOR QDR2_3 = 0.
           
           MOVF    DCValCH1,W
           MOVWF   TPO2                 ;Use value from channel 1 as default

           RRF     FLAGS,W              ;Bit 4 and 5 are the half round flags
           ANDLW   10H                  ;Mask all other bit flags in W
           XORWF   FLAGS,W              ;Do EXOR function
           ANDLW   10H                  ;and again mask everything not needed
           BTFSS   STATUS,Z             ;If 0, select channel2
           GOTO    CHSEL2   
           MOVF    DCValCH2,W
           MOVWF   TPO2                 ;Use value from channel 2
           banksel EEADR                ;Select EEPROM bank
           INCF    EEADR,F              ;and get odd adresses (even are for channel 1)

;use successive approximation to go through the table, table is monotonous, hence possible
;64 datapoints per channel, so 1 LSB =2' lowest bits interplolation between two values not implemented yet
;start at the middle byte:
           
CHSEL2     
          banksel  EEADR
          MOVLW    40h                 ; 64, sinc table is organized in X value, Y value
          MOVWF    TPO1                ;TPO1 is the counter
NXT_APP   MOVF     TPO1,W
          ADDWF    EEADR,F             ;Add offset to pointer
          BSF      EECON1,RD           ;Read the value from EEPROM
          MOVF     TPO2,W              ;Load DC value in W
          SUBWF    EEDATA,W            ;Substract EEDATA from DC-value
          BTFSC    STATUS,Z            ;if value found, stop searching
          GOTO     VAL_FND
          BTFSC    STATUS,C            ;Check which on is larger
          GOTO     NOT_LARG            ;if DC Value is larger, the value is lower in the table
          
          MOVF     TPO1,W              ;EEdata is larger, value higher in the table
          SUBWF    EEADR,F             ;Hence substact the value previous added

NOT_LARG   BCF      STATUS,C
           RRF      TPO1,F              ;Set next value for approximation
           BTFSS    TPO1,0              ;if last bit is set, job done
           GOTO     NXT_APP             ;if not, next value   
 
........


       org 0x2100
EE_ROTF

       de      8Fh,0Dh,18h,42			; 1.000.000/16 usec, result in speed in 1/24 m/hr
                                        ; 1 m/s = 1omw/ sec = 1e6 usec = 1e6 clockticks
                                        ; 1e6/16 = 62.5e3 9375000/62.5e3 = 150 150/42 = 3.658 km/hr 
       de      42,67,77,1               ; last byte second division, 42 for km/hr, 67 for mph and 77 for knotes) 
	

;Angle references, start with 26' in steps of 2' for X and Y
TABLEREF            DE     206   ,  214
                    DE     205   ,  213
                    DE     203   ,  211      ;30
                    DE     201   ,  209
                    DE     200   ,  208
                    DE     198   ,  206
                    DE     196   ,  204
                    DE     194   ,  202      ;40
                    DE     191   ,  199
                    DE     189   ,  197
                    DE     187   ,  195
                    DE     184   ,  192
                    DE     182   ,  190      ;50
                    DE     179   ,  187
                    DE     176   ,  184
                    DE     174   ,  182
                    DE     171   ,  179
                    DE     168   ,  176      ;60
                    DE     165   ,  173
                    DE     162   ,  170

Iemand enig ervaring hierin, of werkt de simulator niet zoals-ie zou moeten werken met EEPROM data?

Welke PIC ?
Waar EEADR en EEDATA zitten varieert per kreng.
Ik heb er nooit problemen mee gehad, dus ik denk dat er een foutje in de code zit.

De PIC in kwestie is een 16F876, Even wat proberen, misschien weet ik waar dan het foutje zit...

[edit]
wat geprobeerd in de header file... met nog steeds hetzelfde resultaat in de simulator
[/edit]

[edit2]
Inderdaad foutje in de code... EECON1 zit in een andere bank dan EEADR en EEDATA, even over het hoofd gezien, dank voor het meedenken...
[/edit2]

[Bericht gewijzigd door LaStei op ]