This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Simulating a hex display timer

I am helping a student with his assignment.

80C517A Microcontroller.
U-Vision Keil compiler and d-scope debugger.

The first task is to simulate a microcontroller based "egg timer" with which the user inputs the required time in seconds (range 0 to 99) via an input port by simulating a two pin shaft encoder.

The time is then displayed using the serial window.

The second task is to implement the program on the target hardware. In this case the time should be displayed using the hex display board JK6.

These tasks are to make use of the on board timer and interrupt facility of the microcontroller.

If anyone can help with the following questions, it would be greatly appreciated as the student needs to understand this before Monday 14th May 2001.

Thanks.

Andrew Pearse
ABPC Ltd
+44 1845 524222

Questions

Q1. What is a two pin shaft encoder and how could it be simulated with U-vision? (ie what port would it connect to and what addresses would need to be read by the C program?)

Q2. Can the interrupt facility of the microcontroller be simulated and how, using a C program?

Q3. How can the on-board timer of the microcontroller be set-up and used, with a C program?

Q4. Is there any information about the JK6 hex display board? How does it connect to the microcontroller? How does the C program set the display values of the JK5?

END OF MESSAGE

  • "I am helping a student with his assignment."
    I hope you are actually helping him, and not just doing the assignment for him.

    He should visit the library, and try a goood internet Search engine.

    The first thing is to get him to read the "Getting Started with µVision2" manual (gs51.pdf), and work through the examples.

    Note that the entire documentation set is available online via the 'Books' tab of the uVision Project window.



    "U-Vision Keil compiler and d-scope debugger."
    uVision isn't a compiler.
    If you have uVision, why are you using dScope?
    I think you'll find the uVision debugger & simulator much "friendlier"


  • Thanks for the advice.

    "uVision isn't a compiler
    If you have uVision, why are you using dScope?"

    The student has uVision version 1 and dScope, as provided on CD from the University. I am using a trial version of uVision version 2 as downloaded from the Keil website. As I understand it, uVision version 1 does not include a debugger facility, thus dScope is being used.

    If uVision is not a compiler, what is doing the compilation of the C program?

  • The student has uVision version 1 and dScope, as provided on CD from the University

    Why is the university teaching on outdated tools?
    Free CDs with evaluation versions of the lates tools are available from Keil.

    If uVision is not a compiler, what is doing the compilation of the C program?

    the compiler - C51.exe - of course!

    uVision is just a GUI front-end which provides you with an editor and Project manager; from the options you choose in the GUI dialogues, uVision just creates appropriate command lines for the compiler (C51.exe), assembler (A51.exe), linker (BL51.exe), etc.
    You could do it all without uVision - using a 3rd-party editor and make instead.

  • "Why is the university teaching on outdated tools?"

    Good question. My guess is that it may be down to cost.

    "the compiler - C51.exe - of course!"

    Thanks for the explanation. You help is very much appreciated.

  • Q1. What is a two pin shaft encoder and how could it be simulated with U-vision? (ie what port would it connect to and what addresses would need to be read by the C program?)

    You can implement debug functions that can send the simulated shaft encoder data to the microcontroller's port. The port to use is up to you, you just need to consider the internal port construction and pin functions to choose it, each port has it own address.

    Q2. Can the interrupt facility of the microcontroller be simulated and how, using a C program?

    You can simulate interrupts with the interrupt function parameter.

    void dunno ( void ) interrupt N

    Consult the manuals for more information.

    Q3. How can the on-board timer of the microcontroller be set-up and used, with a C program?

    You can apply the same method that you used to do using assembly. ( the same idea )
    TMOD = 0x??;
    and so on...

    Consult your 80517 user's manual for delails about Timer/Counter operation modes.



  • Thanks.

    As an example of implmenting a debug function, might you set up a button in the toolbox so that when clicked it sets a pin value of a port, thus simulating the output from the shaft encoder? Am I on the right track?

  • As an example of implmenting a debug function, might you set up a button in the toolbox so that when clicked it sets a pin value of a port, thus simulating the output from the shaft encoder? Am I on the right track?

    Yeah! You got it!

    You can start a whole process with this button for example...

    There's a Example with the uVision 2 called TRAFFIC that shows debug functions implementations...

    Folder:

    \examples\traffic\

  • Thanks for your help. Much appreciated.

  • You can simulate interrupts with the interrupt function parameter.

    void dunno ( void ) interrupt N


    Incorrect: the interrupt keyword specifies that the function is an interrupt service routine, and tells the compiler the interrupt number (N) so that it can "plant" the vector; it does not simulate an interrupt.

    In uVision2, you'd just click on the appropriate flag, or use a Debug Function.
    Software can trigger interrupts by setting the appropriate flag; eg,
    RI = 1;

  • Yeah,

    This parameter alocate a vector.. blá bla bla... correct!

    Try to simulate a ISR that read a encoder without an implementation of the ISR. ;-)

    After the implementation you can set the flag and see your ISR working.