예제 #1
0
        public void timerCount(uint cycles)
        {
            RegArrayHandler regArrayHandler = new RegArrayHandler();

            if ((regArrayHandler.getRegArray(0x81) & 0b00001000) == 0)
            {
                if ((regArrayHandler.getRegArray(0x81) & 0b00100000) == 0)
                {
                    Console.WriteLine("Timer mit Befehlstakt erhöht!");
                    if ((DataStorage.prescalerCount + cycles) >= DataStorage.prescalerValue)
                    {
                        if (regArrayHandler.getRegArray(0x01) == 255)
                        {
                            regArrayHandler.setRegArray(0x0B, regArrayHandler.getRegArray(0x0B) | 0b00000100);
                            //triggerInterrupt();
                            regArrayHandler.setRegArray(0x01, 0);
                            DataStorage.prescalerCount = 0;
                        }
                        else
                        {
                            regArrayHandler.setRegArray(0x01, (regArrayHandler.getRegArray(0x01) + 1));
                            DataStorage.prescalerCount = 0;
                        }
                    }
                    else
                    {
                        DataStorage.prescalerCount = DataStorage.prescalerCount + (int)cycles;
                    }
                }
예제 #2
0
 public void checkInterrupt()
 {
     if ((regArrayHandler.getRegArray(0x0B) & 0x80) == 0x80)
     {
         //Timer
         if (((regArrayHandler.getRegArray(0x0B) & 0x20) == 0x20) && ((regArrayHandler.getRegArray(0x0B) & 0x04) == 0x04))
         {
             DataStorage.stack1.SetValueToStck(Pcl.getPCL());
             Pcl.setPCL(0x04 - 1);
             regArrayHandler.setRegArray(0x0B, (regArrayHandler.getRegArray(0x0B) & 0b01111111));
         }
         //RB0
         if (((regArrayHandler.getRegArray(0x0B) & 0x10) == 0x10) && ((regArrayHandler.getRegArray(0x0B) & 0x02) == 0x02))
         {
             DataStorage.stack1.SetValueToStck(Pcl.getPCL());
             Pcl.setPCL(0x04 - 1);
             regArrayHandler.setRegArray(0x0B, (regArrayHandler.getRegArray(0x0B) & 0b01111111));
         }
         //Rb7-4
         if (((regArrayHandler.getRegArray(0x0B) & 0x08) == 0x08) && ((regArrayHandler.getRegArray(0x0B) & 0x01) == 0x01))
         {
             DataStorage.stack1.SetValueToStck(Pcl.getPCL());
             Pcl.setPCL(0x04 - 1);
             regArrayHandler.setRegArray(0x0B, (regArrayHandler.getRegArray(0x0B) & 0b01111111));
         }
     }
 }
예제 #3
0
        public static void checkWatchdog(uint cycles)
        {
            timeNeeded = 0.018;
            if (!DataStorage.watchdogEnabled)
            {
                return;
            }
            //watchdog hat prescaler
            if ((regArrayHandler.getRegArray(0x81) & 0b00001000) != 0)
            {
                timeNeeded = timeNeeded * DataStorage.prescalerValue;
            }


            if (DataStorage.watchdogValue >= timeNeeded)
            {
                Initializer.otherReset();
                MainWindow.WatchdogReset();
            }
            DataStorage.watchdogValue = DataStorage.watchdogValue + (4.0 / ((double)DataStorage.quarzfreq)) * (double)cycles;
        }
예제 #4
0
        private void UpdateSFR()
        {
            string wreg;

            wreg      = DataStorage.w_register.ToString("X2");
            View.WReg = wreg;

            string pcl;

            pcl      = PCL.getPCL().ToString("X2");
            View.PCL = pcl;

            string pclath;

            pclath      = PCL.getPCLLath().ToString("X2");
            View.PCLATH = pclath;

            string status;

            status      = regArrayHandler.getRegArray(0x03).ToString("X2");
            View.STATUS = status;

            string fsr;

            fsr      = regArrayHandler.getRegArray(0x04).ToString("X2");
            View.FSR = fsr;

            string option;

            option      = regArrayHandler.getRegArray(0x81).ToString("X2");
            View.OPTION = option;

            char[] statusarray;
            statusarray             = Convert.ToString(regArrayHandler.getRegArray(0x03), 2).PadLeft(8, '0').ToCharArray();
            View.StatusRegisterData = statusarray;

            char[] optionarray;
            optionarray             = Convert.ToString(regArrayHandler.getRegArray(0x81), 2).PadLeft(8, '0').ToCharArray();
            View.OptionRegisterData = optionarray;

            char[] intconarray;
            intconarray             = Convert.ToString(regArrayHandler.getRegArray(0x0B), 2).PadLeft(8, '0').ToCharArray();
            View.IntconRegisterData = intconarray;

            string timer;

            timer      = regArrayHandler.getRegArray(0x01).ToString("X2");
            View.Timer = timer;

            string prescaler;

            prescaler      = ("1:" + DataStorage.prescalerValue.ToString());
            View.Prescaler = prescaler;

            string pcintern;

            pcintern      = DataStorage.programCounter.ToString("X4");
            View.Pcintern = pcintern;

            double time;

            time = (double)DataStorage.watchdogValue * 1000000;
            if (time <= 1000)
            {
                View.Watchdog = time.ToString("n0") + " µs";
            }
            else
            {
                time          = time / 1000.0;
                View.Watchdog = time.ToString("n3") + " ms";
            }
        }