One-chip computer programming experience

Document Sample
One-chip computer programming experience  Powered By Docstoc
					One of the experiences: Use " software trap + procedure password " The ball which
deals with PC indicator flies as CPU is interfered with by the external world, PC
indicator will fly to another segment procedure sometimes, or jump to the leader. In
fact, if PC indicator flies to the leader, might as well deal with. So long as set up the
software trap (interception order) in the leader ,Intercept the procedure in initialized
Section or procedure error handling section. However, if PC indicator flies to another
segment procedure, how to do the system? The little craftsman recommends a method
here - -Procedure password, the thinking is as follows: 1, First of all, the procedure
must modularize. Every module ' Subroutine) Carry out a function. Each module has
an export (RET) only . 2,Set up a piece of module ' Subroutine) ID register. 3,It is
each subroutine that disposes an only ID number. 4,Whenever the subroutine finishes,
return (RET) Before this, after sending ID number of the notebook procedure and
entering the ID register 5, returning to the procedures of higher authorities first, judge
ID number in ID register first. If is correct, continue carrying out; If is incorrect, show
PC indicator has probably already been jumped by mistake, the subroutine has not
returned according to the predicted export, intercept the initialized Section or program
error of the procedure at this moment and pay attention to section. This kind of
method, like setting up several sentry posts in the procedure, after transferring the
return from a subroutine each time, want the password (ID number)
correctly ,Identifying and releasing behind. And then cooperate with the software trap,
can basically play most PC indicators the phenomenon of flying to detect. Have
reached the procedure error handling section, kill and cut (cold start is still the hot
starting) By you. Announce the essence that the procedure run fast only with a code!
750102H; MOV 01H, # 02H if PC to point to 75H at present, but point to 01H or 02H,
then 51 inner command decoders will translate into AJMP XX01H or LJMP XXXXH
them into faithfully but what will XX01H XXXXH be? It knows! So malignant to run
fast that is not fixed! Reform: CLR A ; 0C4HINC A ; 04HMOV R1, A ; 0F9HINC A ;
04HMOV @R1,A; 86H every byte code can't be produced and skipped and circulated,
and all single byte instructions! Run to that? Running out wants oneself to come back!
" at home " It is fine in a thousand days! " jump out " Everything is difficult! Only
used to using accumulator and register to pour counting at ordinary times like this,
give, pour out dangerous code those, like this although " foot " to give PC The ones
that have and add the two bytes " Wrap up " It is not good " Run " Ah! " the foot
wraps up " ====Run! There are friends that will ask: If PC pays special attention to
making 02H --LJMP has paid special attention to making old nose far XXH, has YYH
and then paid special attention to making next door been used? Propose such a
question the intersection of ZENYIN and the the intersection of drill and ox horn can
mention only! Is PC, that top, active? PC0! " tear and abduct " Obviously happen on
her, as for that comrade PC15, the pig is the same that sleep soundly, the thunder is
exploded ' It is interfered with that strong) Come to wake up? In addition if all
interfere with so strong that all make mistakes stage! Shut-off! Shut-off! Non- dry! " it
is not us not all right but the enemy is too strong " ! Conversely if the enemy just
comes out to smash and do mischief once in a while under your dictatorship, but dash
to the west of the wind (PC) once coming out On the senior level, will ask soon
whether it is your kingdom foundation (hardware) or not If have any further problems?
But not happen and take notice of and know the shape ' Software) Have! Based on
hardware! The software is in order to mark! Treat both principal and secondary aspect
of disease, cast strong physique, can one hundred poison invade! Second of, don't
readily believe dog's discussions about the software dog of software experiences are
many on forums. The artisan has ever consulted a lot of articles about the software
dog too. Some masters have really proposed some more skillful methods. However,
the artisan's sincere advice is: Don't readily believe the software dog! In fact, the
software dog is equivalent to a kind of self-containment behavior of the software. The
general thinking passes and sets up a counter, to +1 of its in timer interrupt, to its clear
in the appropriate place of the main program. If the procedure is out of control, the
clear order has not been carried out, but stop making and often happening, then the
counter overflows ' The dog barks) . But there is a issue here: In case the interference
results in stopping being shielded, dog of that software will never bark! --To this kind
of possibility, someone proposes breaking in the main program repeatedly stopping to
make can mark, guarantee not to allow cutting off and is shielded. --But in case the
procedure flies to a certain dead loop, no longer carry out " to break stopping to make
can mark " This function, or probably live the dog vivid and die of hunger. So, the
artisan's view is: The watchdog must have independent counters. (namely hardware
watchdog) Fortunately many chips all offer internal WDT now. It is since with
counter that this kind of dog is all. Even if the interference causes the procedure to be
out of control, WDT will be made and often counted until overflowing. Certainly, the
artisan has no meaning wanting to kill all a rod of software dog. No matter soft dog or
hard dog after all, capturing to the mouse is a good dog (dog takes mice -
-Officious? ). If a of standard dog expert has really raised a good software dog that
can guard the gate, please lead to let everybody see. Experience third of talking about
the intersection of RAM and redundancy to be so-called and RAM redundant: 1,
Important the intersection of data information and the intersection of backup and 2 '
Or the above) Leave different areas in the RAM in ' Mean the address does not link
up) . 2,As usual go on, revise to data these, upgrade 3 backup at the same time,
intercept into " the intersection of procedure and the intersection of error handling and
piece " as interference generation When the China, do, compare data with backup,
adopt the intersection of vote and way (the minority is subordinate to the majority)
Elect correctly (is or the possibility correct? )Then piece. 4,The more backups are, the
better the result is. (certainly, you must have sufficient storage space) 5,Only the most
original data of the backup. Intermediate variable ( Mean those data that can be
derived out from the basic data again) Needn't back up the note: 1, The theoretical
foundation of this kind of thinking, it is said that comes from a kind of " theory of
probability " ,Namely one it plays wife probability of face to be very large, but if he
seal face go to work, find the whole the intersection of company and each married
face of man blue and green, this kind of probability is very little. The same, the
probability that a piece of RAM register data is destroyed by rush of water is very big,
but the probability that a plurality of RAM that the address does not link up is
destroyed by rush of water at the same time is very little. 2,The past two years, little
craftsman, when the apprentice, used a method like this, but the result was not very
ideal. Feel it may be that the theory of probability had failed in this of mine at that
time? Looking back, it may be the fault that the opportunity of the backup select. The
data and backup that the result will be already destroyed by rush of water has been
entered. Since like this, the data resumed are just wrong naturally. There is a friend to
ask the redundant order in the fourth of, talks about order redundancy in the front
experience, according to the artisan's understanding, the order is redundant, but
movements are redundant. For example, you should export a high level to drive a
external device on a certain delivery port, if you only send it once off " 1" ,Then,
when the interference comes, this " 1 " May turn into " 0" (used after a verb to
indicate the completion of an action). Accurate processing mode, you break the " the 1
" regularly . Then, even been interfered with accidentally, it can resume. Except the
redundancy of I/O mouth movements, the artisan proposes everybody below strongly
the different fields adopt this kind of method too: 1, Display of LCD. Sometimes,
perhaps you will use the specialized drive chip of some LCD (such as HT1621) ,This
kind of chip has an advantage, namely you only convey the view data to it, auto
scanning LCD that it will be constant. However, you must not think what thing have
no you in this way. The accurate processing mode is, should remember breaking
giving and showing the data (even reveal the content has not changed) regularly .
Self-carrying LCD DRIVER as to CPU one, should break LCD RAM regularly too.
2,Can enable to stop the arrangement of the sign. Don't think you would stop setting
up in the procedure initialisation section on OK well. Should break in the main
program regularly in the appropriate place, in case that your break is hung up. 3,Some
other marks word and parameter register ' Including your one's own definition) ,Also
remember often breaking. 4,Some other you think necessary place that break
repeatedly. Fifth of experience, devoting under filtering method of 10 kinds of
software - -Artisan take infinite pains, search intestines, blow belly, contemplate,
scrape together, put 10 the intersection of software and filtering 1 method, the
intersection of amplitude limit and filtering law that come out in order ' Also called
the procedure and judged the filtering law) A, method: According to experience
judgement, confirm that samples amount of deflection of acceptable maximum (set as
A) twice The judgement until new value of each detection: Value difference of and
value last time that if this time & lt; =The intersection of A, effective value this and
this value & gt; A, this value is invalid, give up this value, use the value to replace this
value B, advantage last time: It is unable to inhibit that kind of periodic interference
smoothness filtering laws A, methods of poor place value 2, middle to overcome the
impulse interference C, shortcoming caused by accidental factor effectively:
Continuous sampling N time (N chooses the odd number) It is this mean value B,
advantage to arrange N sampled value once according to the magnitude and fetch the
intermediate value: Can overcome the fluctuation interference caused by accidental
factor effectively and have good filtering results C, shortcomings on temperature,
slow parameter examined of change in liquid level: To which flowrate, speed,etc.
change fast for parameter should not 3, arithmetic mean law A, method filtering:
Fetch, carry on the intersection of arithmetic and value, N of average calculating
operation, when being relatively loud by n sampled value continuously: The
smoothness great of the signal, when the lower N value of the degree of sensitivity is
minor: The signal is lower in smoothness, but the great N value of degree of
sensitivity is chosen: General flowrate, N =12; Pressure: N =4B, advantage: Suitable
for having a mean value in generally having the characteristics that the signal of the
random disturbance filters such signal, signal C, shortcoming of fluctuating up and
down near a certain number range: For measure slow speed or require data the
intersection of calculated speed and quick real time control does not suitable to apply,
waste RAM4, the intersection of recursion and average filtering law relatively ' Also
called the filtering law of overlapping average) A, method: Fetch, regard as, fix,
sample, reach first new data put the back of the queue into each time for N by one the
intersection of team and length listed to line up by n sampled value continuously, and
in fact throw away a datum of team's head. (first-in first-out principle) Carry on the
average calculating operation of arithmetic of n data in the queue, the ones that can
obtain new N value of fruiting of filtering are chosen: Flowrate, N =12; Pressure: N
=4; Liquid level, N =4~12; The temperature, N =1~4B, advantage: Have good inhibit
function on periodic interference, high to suitable for high-frequency vibratory the
intersection of system and C, shortcoming smoothness: Low degree of sensitivity
inhibit function of interference discrepancy to dispel caused by impulse interference
the intersection of sampled value and deflection suitable for impulse interference
compare while being difficult to pulse that appear accidentally Severe occasion waste
RAM5, middle the intersection of place value and average filtering law relatively '
Also called defending the average filtering law of impulse interference) A, method:
Equivalent to " The filtering law of China's place value " + " filtering law of
arithmetic mean " N data of continuous sampling, remove a maximum value and a
minimum then calculation N-2 a machine format arithmetic mean N value is chosen:
3~14B, advantage: Have merged the advantages of two kinds of filtering laws to the
pulse interference appearing accidentally, can dispel the deflection C of sampled value,
shortcoming caused by impulse interference: It is relatively slow to measure the speed,
relatively waste RAM6, amplitude limit average filtering laws A, methods as filtering
law of arithmetic mean: Equivalent to " The filtering law of amplitude limit " + "
average filtering law of recursion " New data arrived to sample carry on amplitude
limit deal with first each time, send queue into, carry on the intersection of recursion
and average the intersection of Shelving and B, advantage and then: Have merged the
advantages of two kinds of filtering laws to the pulse interference appearing
accidentally, can dispel the deflection C of sampled value, shortcoming caused by
impulse interference: Relatively waste RAM7, first order filtering laws A, methods of
lagging behind: Fetch a =Filtering result once of 0~1 =( 1-a) *This sampled value +a
B, advantage that filtering fruited of * last times: Have good inhibit function that is
suitable for the more high occasion C of the wave frequency, shortcoming to periodic
interference: Phase delay, the low intensity of lagging behind of the degree of
sensitivity is fetched Can't be dispelled and strained 1/2 of the undesired signals 8,
weighting recursion average filtering laws A, methods that wave frequency is higher
than sampling frequency in the magnitude of A value: It is to the improvement of the
average filtering law of recursion, namely the different right of data at different
moments is usually, close to the data carved now, right obtains the more greatly. The
bigger the weight coefficient offering sampled value newly is, then the higher the
degree of sensitivity is, but signal B, advantage the lower in smoothness: Suitable for
having greater and purer target and sampling period shorter system C, shortcoming of
the time constant of lagging behind: As to pure to lag behind time constant to be
minor, sampling period longer, can't change slow signal fast the intersection of
reactive system and severity interfered with at present, the filtering laws A, methods
that filtering result is lack of 9, disappear and tremble: Set up a filtering counter and
compare sampled value each time with present mean value: If sampled value =Present
mean value, then clear of counter sampled value & lt; > Present mean value, then the
counter +1, and judge whether the counter is & gt; =Upgrade N (overflow) If the
counter overflows, replace present mean value of this value, and clear counter B,
advantage: Have better filtering results to the parameter examined changed slowly,
can avoid the repeated opening/closing beating or C, shortcoming that the number
value shakes on display unit of the control device near marginal value: Happen to be
the disturbed value as to the value sampled that time that the parameter changed fast
should not overflow in the counter, will interfere with making mean value to
introduce filtering laws A, methods into system 10, amplitude limit and disappear and
tremble worthwhily: Equivalent to " The filtering law of amplitude limit " + "
disappear and tremble and strain the wave law " First amplitude limit, and then
disappear and expose B, advantage: Have inherited " Amplitude limit " And "
disappear and tremble " Advantage improve " Disappear and tremble and strain the
wave law " Some defects of China, avoid introducing disturbed value into system C,
shortcoming: As to the thing that fast parameter of change should not numerical
filtering IIR A. Method: Confirm the signal bandwidth, strain it. Y(n) =a1*Y(n-1) +
a2*Y(n-2) + ... + ak*Y(n-k) + b0*X(n) + b1*X(n-1) + b2*X(n-2) + ... + bk*X(n-k) B.
Advantage: Gao Tong, low-pass, band pass, the band elimination is arbitrary. It is
simple to design (use matlab) C. Shortcoming: Calculation sum is great.
For more information about these, please visit our website at