Delete RAM data and delay function
This commit is contained in:
12
inc/system_function.h
Normal file
12
inc/system_function.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef _SYSTEM_FUNCTION_
|
||||
#define _SYSTEM_FUNCTION_
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
#define RAM_ADDR_START 0x80
|
||||
#define RAM_ADDR_END 0xff
|
||||
|
||||
void ram_erase(uint8_t ram_bank);
|
||||
void delay(uint16_t count);
|
||||
|
||||
#endif
|
||||
34
src/system_function.c
Normal file
34
src/system_function.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "BA45F5250.h"
|
||||
#include "stdint.h"
|
||||
#include "build-in.h"
|
||||
#include "system_function.h"
|
||||
#include "macro_define.h"
|
||||
|
||||
void ram_erase(uint8_t ram_bank)
|
||||
{
|
||||
_mp1h = ram_bank;
|
||||
_mp1l = RAM_ADDR_START;
|
||||
_acc = RAM_ADDR_END - RAM_ADDR_START + 1;
|
||||
while (_acc != 0)
|
||||
{
|
||||
_iar1 = 0;
|
||||
++_mp1l;
|
||||
_acc--;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void delay(uint16_t count)
|
||||
{
|
||||
uint8_t i;
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
#if _HIRCC_8M
|
||||
GCC_DELAY(9993);
|
||||
#elif _HIRCC_4M
|
||||
GCC_DELAY(4993);
|
||||
#else
|
||||
GCC_DELAY(2493);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user