malik_123
Member level 4

I have written the following code to implement the circular buffer ,
code is working for the X-data space fine ,
but
for the Y-data space the same code does not work
i write the data in the two location
1) y-data space
2) x data space
when i implement the code for the x-data space the pointer automatically set to the initial value after the last value.
but in case of Y-data space it does not do so
I am checking the output on Mplab Simulator
code is working for the X-data space fine ,
but
for the Y-data space the same code does not work
Code:
#include <30F4013.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOCKSFSM //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES WPSB16 //Watch Dog Timer PreScalar B 1:16
#FUSES WPSA512 //Watch Dog Timer PreScalar A 1:512
#FUSES PUT64 //Power On Reset Timer value 64ms
#FUSES NOBROWNOUT //No brownout reset
#FUSES BORRES
#FUSES MCLR //Master Clear pin enabled
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES ICSP
#use delay(clock=20000000)
#word CORCON = getenv("SFR:CORCON")
#word MODCON = getenv("SFR:MODCON")
#word XMODSRT = getenv("SFR:XMODSRT")
#word XMODEND = getenv("SFR:XMODEND")
#word YMODSRT = getenv("SFR:YMODSRT")
#word YMODEND = getenv("SFR:YMODEND")
signed int16 Circular_Buf[200];
#locate Circular_buf = 0xC00
signed int16 Cir[70];
#locate Cir = 0x800
struct
{
int XWM:4;
int YWM:4;
int BWM:4;
int Reserved:2;
int YMODEN:1;
int XMODEN:1;
}MODCONbits;
#locate MODCONbits = getenv("SFR:MODCON")
void main(void)
{
int i;
for (i=0;i<=40;i++)
{
Circular_buf[i]=i;
cir[i]=(i+23);
}
// setting for Y-data space , W1 is used as the pointer for circular buffer
MODCONbits.XMODEN=0; // X AGU modulus addressing enabled
MODCONbits.YMODEN=1; // Y AGU modulus addressing enabled
MODCONbits.BWM=15; // Disable bit-reveresed addressing
MODCONbits.XWM=15; // Use register W8
MODCONbits.YWM=1; //
// here I shall make a circular buffer in Y-data space , w1 will be a pointer
// i shall move the ciruclar buffer value to W0 register and
// shall view it on Mplab simulator , does not work
#asm
MOV #0xC00,W0
MOV W0,YMODSRT ;set modulo start address
MOV #0xC24,W0
MOV W0,YMODEND ;set modulo end address
MOV #0xC00,W1
NOP
DO #49,FILL ;fill the 50 buffer locations
FILL:
MOV [W1++],W0
#endasm
// setting for X-data space , W2 is used as the pointer for circular buffer
MODCONbits.XMODEN=1; // X AGU modulus addressing enabled
MODCONbits.YMODEN=0; // Y AGU modulus addressing enabled
MODCONbits.BWM=15; // Disable bit-reveresed addressing
MODCONbits.XWM=2; // Use register W8
MODCONbits.YWM=15; // Use register W9
// here I shall make a circular buffer in X-data space , w2 will be a pointer
// i shall move the ciruclar buffer value to W0 register and
// shall view it on Mplab simulator , work properly
#asm
MOV #0x800,W0
MOV W0,XMODSRT ;set modulo start address
MOV #0x824,W0
MOV W0,XMODEND ;set modulo end address
MOV #0x0000,W0 ;W0 holds buffer fill value
MOV #0x800,W2 ;point W1 to buffer
DO #49,FIlLL ;fill the 50 buffer locations
FIlLL:
//MOV W0,[W1++] ;fill the next location
MOV [W2++], W0 ;fill the next location
#endasm
}
i write the data in the two location
1) y-data space
2) x data space
when i implement the code for the x-data space the pointer automatically set to the initial value after the last value.
but in case of Y-data space it does not do so
I am checking the output on Mplab Simulator