Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

8051 Atmel 89C51 programming in C example HELP

Status
Not open for further replies.

8051HELP

Member level 1
Joined
Nov 27, 2015
Messages
32
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
251
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 ...


Below is code which i imagine but dont work correctly...

PLEASE HELP


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#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;
    
    }  }      }  }     }

 

Exactly what problem you are facing ? Kindly elaborate.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top