I need to write only numbers (every second) in string on display (memory mapped on 0x8001 adress) which are divding with 2 .
I must use counter not delay () for interrupt ...
Code:
#include <reg51.h>
#include <math.h>
typedef unsigned char byte;
byte a[3]= {2,1,8};
byte counter, frequency,displ;
int i=0;
byte xdata display _at_ 0x8001;
sbit switcher=P0^0;
void Inic(void) {
EA=1;
ET0=1;
TMOD=1;
TH0=0x3C;
TL0=0xB0;
TR0=1;
counter=1;
frequency=0;
}
void timer0(void) interrupt 1 using 2 {
TR0=0;
TH0=0x3C;
TL0=0xB0;
TR0=1;
if(switcher) {
if(!(--counter)) {
counter=frequency;
display=displ;
}} }
void main(void) {
Inic();
while(1) {
if(switcher) {
for (i=0;i<3;i++) {
if(a[i]/2) {
displ=a[i];
frequency=20;
} } } } }