Dmx Pack Software. 1, Constants. There constants are calcurlated at the begginging. The Insturction rate = Number of Instruction per second. Timer0_cnt = Amount to reload counter tgo create correct delay. Baud_Rate_Constant = Constants for the internal UART StartCode = DMX Satrt Code ( Preset to 0 ) Flags. IFlags, Interupt Flags. These are the flags used within the interupt routien. They are used to capture the stage the software has reached in the DMX recieving function. Flags, General Flags. Usde to store the current settings of the software. DFlag, Display Flags Remembers the current software position in the seven segment display. Variables. The variables for storing the Interupt status values are placed in the common ram position as well as the EE values All the other values are stored in bank 0. 2, Interrupt Routien. On entering the Interupt routien all the status registers are stored in to the common memory. Each source of possible interupt is then polled , with Timer 0 first ( Looking for the next count in the phase angle control) This is then followed by the USART intreupt checking for any DMX data recieved and finally we have the check for the zero crossing pulse, RB0. If no futher sources of interupt are found then the interyut routien is exited , restoring the values that were held before. Interupt on Timer 0 When the timer interupts each channel count is decreased. If any channel count = 0 then it's relivant ouput is set. A counter is also incremented each time. Interupt on RB0 The RB0 port is connected to the zero Crossing input. At the Start of the phase angle control part ( end of the Zero Crossing Pulse ) Timer 0 is enabled and the phase counter is reset. At the End of the scan ( Start of the Zero Crossing Pulse) The timer is disabled , The channel Outputs are reset (Port B) and the chanmnel counter are reloaded. Also the position counter is saved to compare the length of the phase control part. USART Interupt ( DMX Data recieve part.) The DMX recieve is done in a number of stages relating to the parts of the DMX Signal. The current position in the DMX data pattern is stored in the Interupt Flags. The First conditiuont that is checked is that a Hardware Overflow has not occured. Aftre that the 9th Data bit is checked to see if the byte is a start byte. The software then checks for a software framming erroe. Now knowing that the data byte recieved is both usefull and valid the software processes it. Depending on the stage of reception that the software is in depends as to what the software determins the byte to be. If the last byte was a break then this one must be a start byte. If the last byte was a start byte then this one must be a channel. If the last byte was a vlaid channel then this channel could be valid. If the Last channels was the last valid channel we desired then we need to wait for the next break again. Thw Wait break part just clears the USART and set the break detected flag if it was a valid break. The Wait start part checks the start part = 0 and then sets the Start detected flag. The Wait channel part increases the current channel count and if the current channel count equals the desired channel it then sets the valid channels flags. In the valid channels part the recieved is stored in to memory in it's correct place using the channels recieved value. If the channel recieved = the total number of channels required then it clears all the flags cauing the next byte to be looked at by the wait break routien. 3, Main Programme. Start At the beginning all the ports are initalized including the ADC, The switches are then read and the binary switch value is converted to BCD, for display latter. then finally the USART An Interupts and initaizaed. Main In the main programme, if valid DMX data is being recieved then this is loaded straight in to the channel update registers. using Load update registers. if there is No DMX data then either the analogue values are rea if analogue mode is selected iun Get_Analogue_Values or preset values are used from the EEPROM in Preset Mode.