我为PIC18F87做了一个程序,还行。然后我必须把相同的代码迁移到PIC18F4620。该代码具有LCD、UART和七段显示器的接口。最后,所有的问题都在运行…除了EEPROM写函数。这个函数有不稳定的行为。我用的代码和数据表是一样的:EEPROFBCFECONE1,EEPGD;EngDeloBcCfEnEn1,CFGS;1=CONFIG。寄存器,0=闪存O DAT0S.BSFEFEC1,WRE;HabiTeA ECRITURBABCIMCONTRON,GIE;DeHabis
tia中断;MOVLW0x5MOVL2WAXAMOVOVWEF2BSFEFECO1,WR;BSFIMTCON,GIE;Habista中断;用户代码执行;用户代码执行BCFEFECO1,WRN;DeHabista ESCRITURA AL完成(EEIF集)BCFPIR2,EEFEURTURNI AM写入10个连续的循环:CyeDefBANCO,0;BANCO 1MOVWMNCNDMOVLW0XAM0VFWMulPLRCALMYPYS;(BANCO-1)*10MOVFLYBY字节,WMOVWWDATAWAYAXADYDR;Valor表DFSMOVFWFFRSR0LANDERMOVEVFDF0,WMOVWFDATAYEEDATAL写的CurfDATAEE该程序具有用于EUSAT功能的高中断例程。每次接收到来自EUART的消息时,都有中断,称为InIT例程。这个特性运行正常!高科代码0x000 08GotoIndiTI真的混淆了这个PIC中的中断功能。我不知道EEPROM写的问题是由于中断…还是我的代码…或者…我会感谢你们在这个问题上的善意支持。
以上来自于百度翻译
以下为原文
I made a program for PIC18f887 and was OK.
Then I have to migrate the same code to the PIC 18F4620.
The code have interfaces to LCD, UART and 7 segments displays. Finally, all issues are running OK....except the EEPROM write function.
This function has and erratic behavior.
The code I am using to write is the same one of the data sheet:
; RUTINA ESCRIBIR EN EEPROM
WRITE
MOVF DATA_EE_ADDRH,W
MOVWF EEADRH
MOVF DATA_EE_ADDR,W
MOVWF EEADR
MOVF DATA_EE_DATA,W
MOVWF EEDATA ; DATO A SER ESCRITO EN LA EEPROM
BCF EECON1,EEPGD ; SERA EN LA MEMORIA DE DATOS
BCF EECON1,CFGS ; 1=CONFIG. REGISTERS, 0=FLASH O DAT0S.
BSF EECON1,WREN ; HABILITA ESCRITURA
BCF INTCON,GIE ; DESHABILITA INTERRUPCIONES ;
MOVLW 0X55
MOVWF EECON2
MOVLW 0XAA
MOVWF EECON2
BSF EECON1,WR ;
BSF INTCON,GIE ; HABILITA INTERRUPCIONES
; USER CODE EXECUTION
; USER CODE EXECUTION
BCF EECON1,WREN ; DESHABILITA ESCRITURA AL COMPLETAR (EEIF SET)
BCF PIR2,EEIF
RETURN
I am writing 10 consecutive adresses in a loop:
CHEE
DECF BANCO,0 ; BANCO-1
MOVWF MULCND
MOVLW 0X0A
MOVWF MULPLR
CALL MPY_S ;(BANCO-1)*10
MOVF L_BYTE,W
MOVWF DATA_EE_ADDR ; VALOR INICIAL DE DATA_EE_ADDR
MOVLW 0X44 ; VALOR INICIAL DE FSR
MOVWF FSR0L
ANDERE
MOVF INDF0,W
MOVWF DATA_EE_DATA
CALL WRITE
INCF DATA_EE_ADDR,1
INCF FSR0L,1
MOVLW 0X4E
SUBWF FSR0L,0
BTFSS STATUS,Z
GOTO ANDERE
RETURN
The program has the High Interrupt routine for the functioning of the EUSART. Each time its a received message from EUART, there is the interruption and its called the INNIT routine. This feature is running OK!
HIGH_INT CODE 0x0008
GOTO INNIT
I am really confused about how the interruptions function in this PIC. I do not know if the problem with the EEPROM write is due to interruptions...or my code...or.....
I will appreciate your kind support in this issue.