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.

[51] 4 bit up down/counter assembly code

Status
Not open for further replies.

Sy3d

Newbie level 2
Joined
May 20, 2016
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
15
I need help with this problem doing described as below:

The user inputs the MOD number using P3.0 to P3.3. The counting sequence is sent to P1.0 to P1.3. Port P3.4 is used to Start/Stop the counting sequence, when the counter stops and then starts again the counter should continue counting from the previous state. Pin P3.5 is used to select the up/down counting sequence.

The issue is we didn't take anything about counters and timers of the 8051,so if someone can explain how can i write this in assembly :sad:
 

What is your clock?

First write a flow chart or some pseudo-code, e.g.:

Code:
If P3.5=1 then 
     if P1(0:3)=MOD then 
          P1(0:3)=0
     else 
           P1(0:3)=P1(0:3)+1
     end if
else
     if P1(0:3)=0 then 
          P1(0:3)=MOD
     else 
           P1(0:3)=P1(0:3)-1
     end if
end if;

This should help you figure out the assembly code.
 

@barry For now im using 11.0592 mhz clock ,but the problem is i don't know how to convert input P3.0-P3.3 as MOD.. is it 2^input ??
 

Assuming P3.0-P3.3 is a binary number (with P3.0 as the MSB) then the MOD value would be defined as:

P3.0 * 2^3 + P3.1 * 2^2 + P3.2 * 2^1 + P3.3 2^0
 
  • Like
Reactions: Sy3d

    Sy3d

    Points: 2
    Helpful Answer Positive Rating
I meant, you didn't define a pin as a clock into your counter.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top