Current area: HOME ->

Zip File view

MC68705R3 simulator with source


This page allows you to view the contents of a file contained inside a ZIP archive available at Programmer's Heaven. This means you can view the code and find what you need from it without having to download the ZIP file first. If the file contains source code for a language we recognize, we have syntax highlighted it.

Filename displayed: SIM_TIME.C
Found in file: R3ZIP.ZIP

Download: Star Trek
/************************
    Program: 68705R3 simulator
    File: sim_time.c
        initialize and simulate timer tics
************************/

#include "sim.h"

/* #define DEBUG */   /* uncomment to see timer count on prompt line */

static int internal_count; /* counts up to prescaler value */
static int prescale;
static int tcr_copy;
static int previous_timer_ext_in;

sim_timer_init()
/* Called from sim_reset */
{
    int mor;
   
    mor = sim_readf(MASK_OPT_REG);
    internal_count = 0;
    sim_write( TIMER_DATA, 0xFF);

    tcr_copy = 0x40 | (mor & 0x37);

    if (mor & 0x40)     /* TOPT bit (bit 6 in MOR) is set */
        tcr_copy |= 0x10;   /* TIE (Timer external input enable) */

    sim_write( TIMER_CONTROL, tcr_copy )/* Causes sim_timer_ctrl call */
}

sim_timer_ctrl()
/* Called when TCR is written to */
{
    tcr_copy = sim_readf( TIMER_CONTROL);
    if (tcr_copy & 0x08)     /* Prescaler clear */
        internal_count = 0;
    prescale = 1 << (tcr_copy & 0x07);
#ifdef DEBUG
    printf( "Prescale = %d", prescale);
#endif
}

sim_timer_update( ticks)
int ticks;
{
    int tmode, temp, td;

    tmode = tcr_copy & 0x30;  /* TIN and TIE */
    if (tmode == 0x00)
        temp = ticks;
    else if (tmode == 0x10)
    {
        if (timer_external_input)
            temp = ticks;
        else
            temp = 0;
    }
    else if (tmode == 0x20)
        temp = 0;
    else if (tmode == 0x30)
    {
        if (timer_external_input && !previous_timer_ext_in)
            temp = 1;
        else
            temp = 0;
    }
    previous_timer_ext_in = timer_external_input; /* save for next time */

    internal_count += temp;

    /* Prescale should never be 0, but test to prevent hang */
    while ((internal_count >= prescale) && (prescale != 0))
    {
        internal_count -= prescale;
        td = sim_readf( TIMER_DATA);
        td--;
        if (td == 0)
            sim_write(TIMER_CONTROL, tcr_copy | 0x80); /* Timer Interrupt Req */
            /* Note: sim_write causes sim_timer_ctrl to be called */
        if (td < 0)
            td = 0xFF;
        sim_write( TIMER_DATA, td);
    }
#ifdef DEBUG
    td = sim_readf( TIMER_DATA);
    printf( "Internal count = %d, td = %d    ", internal_count, td);
#endif
}


Turbo Pascal case converter version 2.2
UpConv is a case conversion program designed for Turbo Pascal versions 3.0 to 6.0 and TPW 1.0, which can easilly be adapted to newer versions of Turbo Pascal.
Yonpy, which stands for Ye Olde NotePad.
It's designed to be a notepad to keep notes and lists etc straight and in an or derly fashion. Note: Turn off clock first.
Star Trek

Download Turbo Pascal case converter version 2.2 UpConv is a case conversion program designed for Turbo Pascal  versions 3.0 to 6.0 and TPW 1.0, which can easilly be adapted  to newer versions of Turbo Pascal. Download Yonpy, which stands for Ye Olde NotePad. It's designed to be a notepad to keep notes and lists etc  straight and in an or derly fashion. Note: Turn off clock  first. Download Star Trek







Sponsored links

Build IT Knowledge with Current & Trusted Content
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.
Check Out IT Certification Preparation Materials
Sign Up With SkillSoft & Get Access to Training Materials for Over 50 Professional Certifications.
Villanova University Six Sigma & IT Certificate Programs
100% Online programs in Six Sigma, IS Security, CISSP Prep, Business Analysis, Proj. Mgmt. and more!
Localize software in three simple steps
Localize .Net, C/C++ & Delphi apps visually. HTML, HTML Help, XML & databases. Try Sisulizer now!
Delphi Localization Tool Sisulizer (WYSIWYG)
Create multilingual Delphi apps in three simple steps. Localize XML, HTML Help ... Try Sisulizer now


Newsletter | Submit Content | About | Advertising | Awards | Contact Us | Link to us |
© 1996-2008 Community Networks Ltd All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Synchron Data - .NET development.