MCU keeps resetting

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCU keeps resetting

1,221 Views
kacto
Contributor I
Hi, i have a problem with a subroutine i'm using to storage data on gp32. Don´t know why but the mcu keeps resetting everytime that goes in there. I know that because one of the leds that indicates my program is running starts flashing. Here a put the subrutine that uses the data received from the spi module and then saves it into the ram, i´m supossed to receive 512 bytes, so I will fill my entire ram space.
 
ramstart          EQU          $0040
...........
mov       #$00,CONFIG2
mov       #$11,CONFIG1  (LVI and COP disabled)
.........
storage:
         clrh                   ;clears index register high
         clrx                   ;clears index register low
         clc                    ;clears carry bit
         brclr  3,SPSCR,*      
ALMAC1:  mov    #$FF,SPDR       ;send dummy byte
         brclr  7,SPSCR,*       ;wait
         lda    spdr            
         sta    ramstart,x      
         aix    #$01                 ;index register plus one
         cphx   #$01FF          ;already 512 byte?
         bne    ALMAC1           ;if not jump
         rts
 
 
Labels (1)
0 Kudos
2 Replies

355 Views
bigmac
Specialist III
Hello,
 
You will not be able to use the entire RAM space for storage of data.  You will need to allow some RAM for stack usage, and for the variables used by the program.  The reset is likely to be occurring because you are writing over the data within the stack.
 
The amount of stack required will depend on the sub-routine nesting levels, and the stack usage for temporary storage of data.  In addition, the occurrance of an interrupt will require additional stack capacity.
 
If you need to read a whole 512 byte data sector, the resources of the GP32 will not be sufficient.
 
Regards,
Mac
 
0 Kudos

355 Views
kacto
Contributor I
Thanks. I forgot about that, I must pay more attention hehe. Well, thanks again.
 
Regards
0 Kudos