;--------------------------------------------- ;--------------------------------------------- ;--------------------------------------------- ; BootLoader Start procedure ;--------------------------------------------- ;--------------------------------------------- ;--------------------------------------------- IF (TOOLCHAIN & HITECH) psect BootLoaderArea global ELSE Area BootLoaderArea(ROM,REL,CON) ENDIF __Boot_Start: and reg[CPU_SCR1],~CPU_SCR1_ECO_ALLOWED mov [bSSC_KEY1],0 ; Lockout Flash and Supervisiory perations mov [bSSC_KEYSP],0 IF (TOOLCHAIN & HITECH) ;--------------------------- ; Set up the Temporary stack ;--------------------------- ; A temporary stack is set up for the SSC instructions. ; The real stack start will be assigned later. ; global __Lstackps mov a,low __Lstackps swap a,sp ELSE ;------------------ ; Set up the stack ;------------------ mov A, __ramareas_end ; Set top of stack to end of used RAM swap SP, A ; This is only temporary if going to LMM ENDIF M8C_SetBank1 mov reg[OSC_CR0],2 ; Set CPU clock=12 MHz M8C_SetBank0 M8C_ClearWDTAndSleep mov reg[ACB00CR0],05h mov reg[ACB01CR0],05h mov reg[ACB02CR0],05h mov reg[ACB03CR0],05h lcall _Boot_LoadConfigInit ; Configure Boortloader PSoC blocks IF (C_LANGUAGE_SUPPORT) call Boot_InitCRunTime ; Initialize for C language ENDIF ;(C_LANGUAGE_SUPPORT) M8C_SetBank1 and reg[VLT_CR],~VLT_CR_PORLEV or reg[VLT_CR],VLT_CR_3V0_POR M8C_SetBank0 mov reg[INT_MSK0],0 M8C_SetBank0 mov reg[INT_VC],0 lcall _BootLoader __Boot_Exit: jmp __Boot_Exit ; Wait here till power is turned off ;----------------------------------------------------------------------------- ; C Runtime Environment Initialization ; The following code is conditionally assembled. ;----------------------------------------------------------------------------- IF (C_LANGUAGE_SUPPORT) Boot_InitCRunTime: ;----------------------------- ; clear bss segment ;----------------------------- mov A,0 mov [__r0],<__bss_start Boot_BssLoop: cmp [__r0],<__bss_end jz Boot_BssDone mvi [__r0],A jmp Boot_BssLoop Boot_BssDone: ;---------------------------- ; copy idata to data segment ;---------------------------- mov A,>__idata_start mov X,<__idata_start mov [__r0],<__data_start Boot_IDataLoop: cmp [__r0],<__data_end jz Boot_IDataDone push A romx mvi [__r0],A pop A inc X adc A,0 jmp Boot_IDataLoop Boot_IDataDone: ret ENDIF ;(C_LANGUAGE_SUPPORT)