pic18 - Pic18F67K22 不会读取 0x10000 以上的程序存储器
问题描述
我正在为 Pic18F67K22 设备编写引导加载程序。程序数据 0x200-0x1FFFF。引导代码位于 <0x200 的内存位置,不受引导加载程序更新的影响。程序 0x200-0x1FFFF 在编程期间得到正确的值,并通过使用 ICD3 读取 IDE MPLAB8.92 中的设备进行验证。当我运行验证代码时,来自 0x200-0xFFFF 的数据是正确的,但是一旦我到达 0x10000,所有数据都读回为 0x00。我还测试了没有 ICD3 的设备并得到了相同的结果。我还尝试使用 0rg 0x10000 处的查找表进行编译,以从测试中删除引导负载,我得到返回的数据 0x00。程序指针为 21 字节宽,低 + 高 + 高,程序存储器通过 EECON1,EEPGD & EECON1,CFGS 选择。TBLPTRU 在 0x01 处是正确的。我正在从外部闪存设备读取数据。任何想法为什么它不阅读?
bt
bcf INTCON,7 ;// disable ALL interrupts
clrf EE_25LC_addr_L
clrf EE_25LC_addr_H
clrf EE_25LC_addr_U
call Init_Read_Boot ;// Set the 25LC1024 Start read address
movlw 0x00 ;// Set Start
movwf TBLPTRL
movwf File_byte_Counter_Low
movlw 0x02
movwf TBLPTRH
movwf File_byte_Counter_High
movlw 0x00
movwf TBLPTRU
movwf File_byte_Counter_Upper
Program_Loop
lfsr FSR0,0x500
movlw .128
movwf ByteCounter
call ReadProgMem ;// Read block
lfsr FSR0,0x400
movlw .128
movwf ByteCounter
call Read_EEPROM ;// 0x400 Modify buffer with new data for write
;// Erase
movf File_byte_Counter_Low,w
movwf TBLPTRL ;// Set Start
movf File_byte_Counter_High,w
movwf TBLPTRH
movf File_byte_Counter_Upper,w
movwf TBLPTRU
BSF EECON1, EEPGD ;//0x07 point to Flash program memory
BCF EECON1, CFGS ;// 0x06 access Flash program memory
BSF EECON1, WREN ;// 0x02 enable write to memory
BSF EECON1, FREE ;// 0x04 ERASE (gets cleard on completion of Erase cycle)
movlw 0x55 ; Erase block
movwf EECON2
movlw 0xAA
movwf EECON2
bsf EECON1, WR ;// 0x01 ; Start the write
nop
TBLRD*-
;// Write
lfsr FSR0,0x400
movlw .128
movwf ByteCounter
BSF EECON1, EEPGD ;//0x07 point to Flash program memory
BCF EECON1, CFGS ;// 0x06 access Flash program memory
BSF EECON1, WREN ;// 0x02 enable write to memory
call WriteProgMem
MOVLW 55h
MOVWF EECON2 ; write 55h
MOVLW 0AAh
MOVWF EECON2 ; write 0AAh
BSF EECON1, WR ; start program (CPU stall)
movlw .128
addwf File_byte_Counter_Low, F
btfsc STATUS,C
incf File_byte_Counter_High, F
btfsc STATUS,C
incf File_byte_Counter_Upper, F
btfss File_byte_Counter_Upper,1 ;// End of program space (U1)
goto Program_Loop
BCF EECON1, WREN ;// disable write to memory
call delay_7ms
nop
banksel PORTA
bsf LATA,3 ;// EPROM CS (SElECT)
call delay_7ms
;// Add verification here
Jmp_V
banksel EE_25LC_addr_L
clrf EE_25LC_addr_L
clrf EE_25LC_addr_H
clrf EE_25LC_addr_U
call Init_Read_Boot ;// Set the 25LC1024 Start read address
movlw 0x00 ;// Set Start
movwf File_byte_Counter_Low
movlw 0x02
movwf File_byte_Counter_High
movlw 0x00
movwf File_byte_Counter_Upper
Verify_Next_Block
movf File_byte_Counter_Low,w ;// Set Start
movwf TBLPTRL
movf File_byte_Counter_High,w
movwf TBLPTRH
movf File_byte_Counter_Upper,w
movwf TBLPTRU
movlw .128
movwf ByteCounter
Verify_Loop
tblrd *+ ; Fill buffer
movf TABLAT, w
movwf CHK_Program_Byte
movlw 0x00 ;// Read opcode
movwf SSP2BUF
btfss SSP2STAT,BF ;
goto $-2
movf SSP2BUF,w
movwf CHK_Flash_Byte
movf CHK_Program_Byte,w ;// CJNE
subwf CHK_Flash_Byte,w
btfss STATUS,Z
call Exit_fail
decfsz ByteCounter,f
goto Verify_Loop
; bsf LATA,3 ;// EPROM CS (DISABLE SElECT)
movlw .128
addwf File_byte_Counter_Low, F
btfsc STATUS,C
incf File_byte_Counter_High, F
btfsc STATUS,C
incf File_byte_Counter_Upper, F
btfss File_byte_Counter_Upper,1 ;// End of program space
goto Verify_Next_Block
解决方案
在您提出问题之前,首先制作一个像这样的简化测试程序。
;Read high FLASH bytes test
#include "p18f87k22.inc"
; CONFIG1L
CONFIG RETEN = ON ; VREG Sleep Enable bit (Enabled)
CONFIG INTOSCSEL = HIGH ; LF-INTOSC Low-power Enable bit (LF-INTOSC in High-power mode during Sleep)
CONFIG SOSCSEL = HIGH ; SOSC Power Selection and mode Configuration bits (High Power SOSC circuit selected)
CONFIG XINST = OFF ; Extended Instruction Set (Disabled)
; CONFIG1H
CONFIG FOSC = INTIO2 ; Oscillator (Internal RC oscillator)
CONFIG PLLCFG = OFF ; PLL x4 Enable bit (Disabled)
CONFIG FCMEN = OFF ; Fail-Safe Clock Monitor (Disabled)
CONFIG IESO = OFF ; Internal External Oscillator Switch Over Mode (Disabled)
; CONFIG2L
CONFIG PWRTEN = OFF ; Power Up Timer (Disabled)
CONFIG BOREN = SBORDIS ; Brown Out Detect (Enabled in hardware, SBOREN disabled)
CONFIG BORV = 3 ; Brown-out Reset Voltage bits (1.8V)
CONFIG BORPWR = ZPBORMV ; BORMV Power level (ZPBORMV instead of BORMV is selected)
; CONFIG2H
CONFIG WDTEN = SWDTDIS ; Watchdog Timer (WDT enabled in hardware; SWDTEN bit disabled)
CONFIG WDTPS = 1048576 ; Watchdog Postscaler (1:1048576)
; CONFIG3L
CONFIG RTCOSC = SOSCREF ; RTCC Clock Select (RTCC uses SOSC)
CONFIG EASHFT = ON ; External Address Shift bit (Address Shifting enabled)
CONFIG ABW = MM ; Address Bus Width Select bits (8-bit address bus)
CONFIG BW = 16 ; Data Bus Width (16-bit external bus mode)
CONFIG WAIT = OFF ; External Bus Wait (Disabled)
; CONFIG3H
CONFIG CCP2MX = PORTC ; CCP2 Mux (RC1)
CONFIG ECCPMX = PORTE ; ECCP Mux (Enhanced CCP1/3 [P1B/P1C/P3B/P3C] muxed with RE6/RE5/RE4/RE3)
CONFIG MSSPMSK = MSK7 ; MSSP address masking (7 Bit address masking mode)
CONFIG MCLRE = ON ; Master Clear Enable (MCLR Enabled, RG5 Disabled)
; CONFIG4L
CONFIG STVREN = ON ; Stack Overflow Reset (Enabled)
CONFIG BBSIZ = BB2K ; Boot Block Size (2K word Boot Block size)
; CONFIG5L
CONFIG CP0 = OFF ; Code Protect 00800-03FFF (Disabled)
CONFIG CP1 = OFF ; Code Protect 04000-07FFF (Disabled)
CONFIG CP2 = OFF ; Code Protect 08000-0BFFF (Disabled)
CONFIG CP3 = OFF ; Code Protect 0C000-0FFFF (Disabled)
CONFIG CP4 = OFF ; Code Protect 10000-13FFF (Disabled)
CONFIG CP5 = OFF ; Code Protect 14000-17FFF (Disabled)
CONFIG CP6 = OFF ; Code Protect 18000-1BFFF (Disabled)
CONFIG CP7 = OFF ; Code Protect 1C000-1FFFF (Disabled)
; CONFIG5H
CONFIG CPB = OFF ; Code Protect Boot (Disabled)
CONFIG CPD = OFF ; Data EE Read Protect (Disabled)
; CONFIG6L
CONFIG WRT0 = OFF ; Table Write Protect 00800-03FFF (Disabled)
CONFIG WRT1 = OFF ; Table Write Protect 04000-07FFF (Disabled)
CONFIG WRT2 = OFF ; Table Write Protect 08000-0BFFF (Disabled)
CONFIG WRT3 = OFF ; Table Write Protect 0C000-0FFFF (Disabled)
CONFIG WRT4 = OFF ; Table Write Protect 10000-13FFF (Disabled)
CONFIG WRT5 = OFF ; Table Write Protect 14000-17FFF (Disabled)
CONFIG WRT6 = OFF ; Table Write Protect 18000-1BFFF (Disabled)
CONFIG WRT7 = OFF ; Table Write Protect 1C000-1FFFF (Disabled)
; CONFIG6H
CONFIG WRTC = OFF ; Config. Write Protect (Disabled)
CONFIG WRTB = OFF ; Table Write Protect Boot (Disabled)
CONFIG WRTD = OFF ; Data EE Write Protect (Disabled)
; CONFIG7L
CONFIG EBRT0 = OFF ; Table Read Protect 00800-03FFF (Disabled)
CONFIG EBRT1 = OFF ; Table Read Protect 04000-07FFF (Disabled)
CONFIG EBRT2 = OFF ; Table Read Protect 08000-0BFFF (Disabled)
CONFIG EBRT3 = OFF ; Table Read Protect 0C000-0FFFF (Disabled)
CONFIG EBRT4 = OFF ; Table Read Protect 10000-13FFF (Disabled)
CONFIG EBRT5 = OFF ; Table Read Protect 14000-17FFF (Disabled)
CONFIG EBRT6 = OFF ; Table Read Protect 18000-1BFFF (Disabled)
CONFIG EBRT7 = OFF ; Table Read Protect 1C000-1FFFF (Disabled)
; CONFIG7H
CONFIG EBRTB = OFF ; Table Read Protect Boot (Disabled)
__RESET_CODE code 0
nop
nop
goto ContinueCpuInitiation
;
__INTERRUPT_CODE code 8
retfie 1
ContinueCpuInitiation
movlw low Table0
movwf TBLPTRL
movlw high Table0
movwf TBLPTRH
movlw upper Table0
movwf TBLPTRU
;
tblrd *+ ; read into TABLAT and increment
movf TABLAT, W ; get data from Table0 = 1
tblrd *+ ; read into TABLAT and increment
movf TABLAT, W ; get data from Table0 = 2
tblrd *+ ; read into TABLAT and increment
movf TABLAT, W ; get data from Table0 = 3
;... end test
nop
__H code 0x10000
Table0
db 1,2,3,4,5,6,7,8
END
并在 MPAB 模拟器中对其进行测试,因为您可以看到一切正常...
推荐阅读
- javascript - HowlerJS - 音频播放器 - 错误 401(未经授权)
- css - 设置一个三列的 Bootstrap 网格
- html - html中的语法自动循环播放.mp3文件
- docker - docker 卷映射在哪里。在主机上?
- angular - 无法绑定到“dataSource”,因为它不是“table”的已知属性。在角度 5
- go - 无法使用 Go X509 pkg 解析 ECDSA 密钥
- java - Mqtt-Spring Boot 中的集成
- javascript - 如何将动态变量传递给 javascripts .forEach() 函数?
- react-native - 选择选项后如何禁用反应本机选择器
- google-cloud-automl - Google automl_v1beta1 错误“提供的位置 ID 无效”