📄 extram.c
字号:
/************************************************
Demonstration program for sccavr: extram.c
Configures an SDK200 fitted with the external ram
components. Writes a incrementing number to an array
of bytes, then reads it back checking for errors.
Use avrinit3.s90
Ron Kreymborg
************************************************/
#include <avrstdio.h>
#define BYTE unsigned char
#define SIZE 32000
void main(void);
void blink(void);
void delay(void);
BYTE data[SIZE];
void main(void) {
register BYTE value;
register int i;
outp(DDRB, 0xff); // PORTB is output
value = 1;
while (1) { // do forever
outp(PORTB, ~value); // show value
for (i=0; i<SIZE; i++) // fill data array
data[i] = value;
for (i=0; i<SIZE; i++) {
if (data[i] != value) { // check all is ok
outp(PORTB, 0); // turn all on
while (1) // and hang if not
;
}
}
value++; // step to next value
blink(); // blink LED 7
}
}
// Blink LED 7 on PORTB for a few mSecs.
void blink(void) {
register BYTE b;
b = inp(PORTB); // get current value
outp(PORTB, b | 0x80); // ensure 7 off
delay();
outp(PORTB, b & 0x7f); // turn it on
delay();
outp(PORTB, b); // restore whatever
}
void delay(void) {
int i;
for (i=0; i<4000; i++) // about 70mS @ 4MHZ
;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -