RAM測試時有點類似下面的程序(當(dāng)然你可以修改它來使這個測試更全面些)——這里測試的RAM的數(shù)量是特定于PIC16C76的,如果要用于其它單片機型號,你需要查閱數(shù)據(jù)手冊來確定相應(yīng)型號的存儲器范圍。
#include
volatile unsigned char INDF @ 0x0; // not defined in pic.h
main()
{
IRP = 0; /* select bank 0/1 */
FSR = 0x20; /* check bank 0 */
do {
INDF = 0x55;
} while(++FSR != 0x80);
FSR = 0x20;
do {
if(INDF != 0x55)
for(;;);
} while(++FSR != 0x80);
FSR = 0xA0; // check bank 1
do {
INDF = 0x55;
} while(++FSR != 0xF0); // avoid the common area, already checked
FSR = 0xA0;
do {
if(INDF != 0x55)
for(;;);
} while(++FSR != 0xF0);
IRP = 1; /* select bank 2/3 */
FSR = 0x10; /* bank 2 RAM starts at 110 */
do {
INDF = 0x55;
} while(++FSR != 0x70); // last address is 170 (common is 170-17F)
FSR = 0x10;
do {
if(INDF != 0x55)
for(;;);
} while(++FSR != 0x70);
FSR = 0x90; // bank 3 RAM, 190-1EF
do {
INDF = 0x55;
} while(++FSR != 0xF0);
FSR = 0x90;
do {
if(INDF != 0x55)
for(;;);
} while(++FSR != 0xF0);
}
ROM的校驗和就要看情況而定了。并不是所有的PIC單片機都能夠讀它自己的程序存儲器的。部分Flash的型號是可以讀的,但是PIC16C76是不能夠讀的,請查看相應(yīng)單片機的數(shù)據(jù)手冊來確定。
-
ROM
+關(guān)注
關(guān)注
4文章
575瀏覽量
85881 -
RAM
+關(guān)注
關(guān)注
8文章
1369瀏覽量
114849
發(fā)布評論請先 登錄
相關(guān)推薦
評論