Chip: 16F1827
IDE: MPLab 8.92
Language: MPASM
I have been trying to use Linear Memory (RAM) accessed by the FSRn registers. Here is a snippet of the code:
Sorry that is so messy. Those comments helped me identify the issue. I am trying to start in Bank 1 at address 0x0A0 and going 240 or 256 registers. Thus,0x0A0 + 0xF0 = 0x190. Only the low byte is used for "buffsize."
In simulation (MPLab SIM), I am using UART I/O stimulus with register injection from a message file that begins with 0xFF x3 followed by values 0x00 to 0xFF by 1's.
Everything looks fine in the Watch window. FSR1 counts up from 0x20A0 (the '2' is to access linear memory) as expected to the calculated endpoint, i.e., 0x2190 or 0x219F, as the message file is loaded.
The problem is when I read out and monitor FSR0. It counts up just fine for the first 200+ entries, then at 0x2170 it fails and reports only zeros. I looked at the file registers (attached) and found that despite what FSR1 shows in the Watch window, registers starting at 0x120, not 0x0A0 are being filled. Thus, I am running out of memory at 0x24F (contents = 0xC8). Register 0x24F is the end of linear memory.
Question: Why isn't RAM memory starting at 0x0A0 being filled?
The only other RAM being used is Common RaAM at 0x70, No other General Purpose Ram is being used. Is this just a simulator issue?
I thought I would post this for the night owls. In the mean time, I will be modifying the code to start at 0x020 and see if that works and will update accordingly. That may be a few hours , as I am still up from early July 4th.
John
IDE: MPLab 8.92
Language: MPASM
I have been trying to use Linear Memory (RAM) accessed by the FSRn registers. Here is a snippet of the code:
Code:
InitBuff ;FSR0 = oldest/lowest filled, FSR1 newest/highest
movlw low(0x0A0) ;start at B1 GPR
movwf FSR0L
movwf FSR1L
movlw high(0x20A0) ;access Linear RAM
movwf FSR0H ;beginning RAM
movwf FSR1H ;highest filled RAM
; movlw 0x9F ;low(FSR1 maximum)
movlw 0x90 ;0x190= d.240
movwf buffsize
PutRCREG
movlb 0 ;get data to fill ram |B0
btfss PIR1,RCIF ; "
bra $-1 ; "
movlb 3 ; " |B3
movf RCREG,w ; "
movwi ++FSR1 ;ensure empty buffer = 0 good idea?? |B3
movf buffsize,w ;low(FSR1 maximum)
xorwf FSR1L,w
btfss STATUS,2 ;skip if full
bra PutRCREG ;for testing only
GetRCREG
; movlw 0xBE ;0x21^0x9F = 0xBE
movlw 0xB1 ;0x21^0x90 = 0xB1
xorwf FSR0H,w ;0x21^0x9F = 0xBE
xorwf FSR0L,w ;0x9F^0x9F
btfsc STATUS,2
bra BuffMT ;buffer empty
moviw ++FSR0
bra GetRCREG
BuffMT
nop
bra InitBuff
In simulation (MPLab SIM), I am using UART I/O stimulus with register injection from a message file that begins with 0xFF x3 followed by values 0x00 to 0xFF by 1's.
Everything looks fine in the Watch window. FSR1 counts up from 0x20A0 (the '2' is to access linear memory) as expected to the calculated endpoint, i.e., 0x2190 or 0x219F, as the message file is loaded.
The problem is when I read out and monitor FSR0. It counts up just fine for the first 200+ entries, then at 0x2170 it fails and reports only zeros. I looked at the file registers (attached) and found that despite what FSR1 shows in the Watch window, registers starting at 0x120, not 0x0A0 are being filled. Thus, I am running out of memory at 0x24F (contents = 0xC8). Register 0x24F is the end of linear memory.
Question: Why isn't RAM memory starting at 0x0A0 being filled?
The only other RAM being used is Common RaAM at 0x70, No other General Purpose Ram is being used. Is this just a simulator issue?
I thought I would post this for the night owls. In the mean time, I will be modifying the code to start at 0x020 and see if that works and will update accordingly. That may be a few hours , as I am still up from early July 4th.
John
Attachments
-
19.3 KB Views: 1


