EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Replies / So, I need to write only

So, I need to write only

|

Microcontroller › 8051 › Interrupt of 1s -Atmel 89C51 › So, I need to write only

November 27, 2015 at 10:58 am #13527
Mike
Participant

So, 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…

#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/2)       {
            displ=a
;        
        frequency=20;
    
    }  }      }  }     }
 

 

RSS Recent Posts

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise