answersLogoWhite

0


Best Answer

DELAY: MOV TMOD,#00000001B // Sets Timer 0 to MODE1 (16 bit timer). Timer 1 is not used MOV TH0,#0FCH // Loads TH0 register with FCH MOV TL0,#018H // LOads TL0 register with 18H SETB TR0 // Starts the Timer 0 HERE: JNB TF0,HERE // Loops here until TF0 is set (ie;until roll over) CLR TR0 // Stops Timer 0 CLR TF0 // Clears TF0 flag RET

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write delay routine for 1 millisecond using timer 0 of 8051 for 12MHZ crystal frequency?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Why you use 12mhz in 8051 micro controller?

Like many early microprocessors it has a 1mhz internal clock for its' operation. 12mhz is divided internally by 12 to derive this frequency.


Which oscillator is used in 8051?

crystal oscilators mostrly of 11.05.... or 12MHz are used with microcontrollers,


What is 12MHZ crystal oscillator?

An oscillator is something that produces an output that repeats regularly. In the electronics field this will be an electrical waveform, often but not always a sine wave. The most important property of an oscillator is its frequency : the rate at which the output repeats. This is measured in Hertz (Hz for short). One Hertz is one repetition (aka cycle) per second. One MegaHertz (MHz) is one million repetitions per second. One of the problems in designing a high quality oscillator is maintaining the output frequency at the value required. One method is to control it by a quartz crystal; this is cut so that it vibrates mechanically at the design frequency, and is coupled to the electronics by the piezo-electric effect. A 12 MHz crystal oscillator is an electronic circuit, whose output frequency is controlled by a quartz crystal to repeat 12 million times per second. (Note. Oscillators don't have to be electronic. Other examples are a guitar string, a flute or a pendulum. An electronic oscillator is the only one that can be crystal controlled.)


What is 12MHz crystal?

An oscillator is something that produces an output that repeats regularly. In the electronics field this will be an electrical waveform, often but not always a sine wave. The most important property of an oscillator is its frequency : the rate at which the output repeats. This is measured in Hertz (Hz for short). One Hertz is one repetition (aka cycle) per second. One MegaHertz (MHz) is one million repetitions per second. One of the problems in designing a high quality oscillator is maintaining the output frequency at the value required. One method is to control it by a quartz crystal; this is cut so that it vibrates mechanically at the design frequency, and is coupled to the electronics by the piezo-electric effect. A 12 MHz crystal oscillator is an electronic circuit, whose output frequency is controlled by a quartz crystal to repeat 12 million times per second. (Note. Oscillators don't have to be electronic. Other examples are a guitar string, a Flute or a pendulum. An electronic oscillator is the only one that can be crystal controlled.)


Was laptops commercially available in 1991?

Yes, I bought a Fora Laptop, 12MHz, 40Meg HD, 5 Megs of RAM, $3,000.00


What does wireless mean in world war 2?

Condensed DATA on British Army Wireless Sets of the numerical period.Click to the set number e.g. Wireless Set No. 19 to see the photograph. More photographs will be added constantly, the final object will be that a picture is available for each Wireless Set listed below. Note that the quality of some pictures is not optimal. When available, better quality photos shall be posted, this will take some time as I have to visit friends and musea to take these pictures. Ultimately more pages might be added with pictures of the interior and accessories, which were either not listed or not being available when both Volume 1 and 2 were printed. For an overview of most of the pictures in this page see also the Army Wireless Sets Image Directory section.Wireless Set No. 1 was a portable transmitter/receiver, developed in 1933. Use: short range Infantry Brigade, Division and RA Regiment communication. Frequency range 4.2-6.6MHz. MO control. RF output 0.5W. R/T and CW. Range up to 5 miles. Replaced by No. 11 Set.Wireless Set No. 2 was a mobile or ground station transmitter/receiver, developed in 1934. Use: medium/short range Division and Brigade communication. Frequency range 1.875-5MHz. MO control. RF output 7W R/T and 10W CW. Range 9 to 30 miles. Small production only.Wireless Set No. 3 was a mobile transmitter/receiver developed in 1934. Use: medium range communication between Corps and Division and Line of Communication. Frequency range 1.3-3.4MHz. MO control. RF output 400W. Range (roof aerial) 25 miles R/T and 50 miles CW.Wireless Set No. 4 was intended as a semi-mobile transmitter developed in about 1930. Use: long range communication between GHQ and Corps HQ. Frequency range 63-375kHz. MO control. RF output 500W. Range up to 200 miles. CW only. Abandoned.Wireless Set No. 5 was a fixed transmitter developed in 1934. Use: long range point to point for Base/GHQ/Corps communication. Frequency range 200-600kHz and 3-20MHz. MO control. RF output 0.5kW (LP)/2kW HP). Range 2000 miles and more. R/T, MCW and CW. Separate receiver.Wireless Set No. 6 was a fixed transmitter developed in about 1934. Use: Army Chain Station. Frequency range 3-25MHz. MO control. RF output 1.5kW. CW only. Range world wide. Only two were made. Separate receiver.Wireless Set No. 7 was a mobile transmitter/receiver developed in 1935. Use: communication between tanks. Frequency range 1.875-5MHz. MO/crystal control. RF output 5W. R/T and MCW. Range 3-5 miles. Unusual shape to fit in bulge of tank. Only a limited number were produced. Replaced by No. 9 Set.Wireless Set No. 8 was a man pack transmitter/receiver developed in 1940. Use: short range communication in Company and Battalion HQ. Frequency range 6-9MHz. MO control. RF output 0.25W. R/T only. Range up to 5 miles. Limited production only. Replaced by No. 18 Set.Wireless Set No. 9 was a mobile transmitter/receiver developed in 1939. Use: medium range communication for AFV and Divisional Signals, vehicle station in truck and ground station. Frequency range 1.875-5MHz. MO/crystal control. RF output 5W/10W. R/T, MCW, CW. Range up to 35 miles. First really successful tank set. There was also a Canadian version of this set, and a later Mk.I Canadian version..Wireless Set No. 10 was a mobile radio relay system developed in about 1944. Use: Line of Communications radio relay providing 8 duplex telephone channels. Frequency band 4.4/4.8 GHz. Range 50 miles (optical). Pulse width modulation.Wireless Set No. 11 was a portable transceiver developed in 1938. Use: general purpose low power set. Used as a vehicle station (truck/AFV), ground station and animal pack station. Frequency range 4.2-7.5MHz. MO control. RF output 0.6-4.5W. R/T and CW. Range up to 20 miles. Very successful design, superseded by No. 19 and 22.Wireless Set No. 12 was a ground station/vehicle station transmitter developed in 1941. Use: general purpose transmitter for Line of Communication. Frequency range 1.2-17.5MHz. MO or crystal control. RF output 7/25W. R/T, MCW and CW. Range up to 60 miles. Normally associated with Reception Set R107.Wireless Set No. 12HP was a vehicle station transmitter developed in 1942. Use: general purpose transmitter for Line of Communication. Frequency range 1.2-17.5MHz. MO or crystal control. RF output 250/350W. R/T, MCW and CW. Range 100 miles R/T or more. Normally associated with Reception Set R107. Is principally a No.12 Set with separate RF power amplifier.Wireless Set No. 13 was an experimental man pack transceiver developed in about 1936. Use: short range Infantry and tank communication. Frequency range 51-64MHz. MO control. RF output 0.3W. R/T only. Range up to 1 mile. Limited issue only.Wireless Set No. 14 was a mobile transmitter/receiver developed in 1940. Use: Short-range R/T communication between a group of HQ tanks or AFV's. Frequency range 290-410kHz. MO control. RF output 5W. R/T only. Range up to 1 mile.Wireless Set No. 15 was a high power static transmitter developed in about 1951. Use: Static transmitter for long range communication, employed in Army Chain Stations. Frequency range 3-25.6MHz. MO/crystal control. RF output 0.5-30kW. R/T (AM and SSB), FSK, CW. World wide range. Commercial Marconi set, renamed Wireless Sender E10. Separate receivers.Wireless Set No. 16 was a high power jammer transmitter developed in 1940. Use: high power transmitter for jamming enemy radio communications in the field. Frequency range 0.86-7.6MHz. MO control. RF output 1.5kW. R/T, MCW, CW. Effective jamming range 25 miles. Limited use and production.Wireless Set No. 17 was a portable transceiver developed in about 1941. Use: small ground station for communication between searchlight Section HQ and detachments, AA batteries or Royal Engineers detachments. Frequency range 44-64MHz. MO control. RF output 0.3W. R/T only. Range up to 15 miles. Accessories and inside views are posted in the Gallery.Wireless Set No. 18 was a man pack transmitter/receiver developed in 1940. Use: portable man pack for short range communication in forward areas between Battalion HQ and Company HQ. Frequency range 6-9MHz. MO control. RF output 0.25W. R/T, CW. Range up to 10 miles. No. 68 Set is similar but with different frequency range. Standard WW2 set.Wireless Set No. 19 was a mobile transceiver developed in 1941. Use: primary developed for AFVs but later also used as general purpose set in truck and ground stations. Frequency range 'A' set 2-8MHz; 'B' set 229-241MHz. MO control. R/T, MCW, CW. RF output 'A' set 2.5-9W. Range 'A' set up to 15 miles; 'B' set 3/4mile. Standard WW2 set.The prototype resulted in the Mk.I, soon followed by the Mk.II and later Mk.III models.RF Amplifier No. 2 increased the range to 45 miles.Wireless Set No. 19 TH was an experimental trials model for the Dutch Army, developed after WW2. Based on a British 19 Set Mk.III, with IC and B set removed, it had an extra frequency range extending the coverage up to 12MHz. MO control. R/T, MCW, CW.After WW2, the Wireless Set No.19 was adopted in other countries, for example the Canadian (USA?) No.19 Mk.II used in the Danish Army and the refurbished Canadian No.19 Mk.III used in theItalian ArmyAfter WW2 a number of Canadian No.19 Mk.III sets were refurbished for use in the British Army. There was also a (believed locally produced) British No.19 Mk.III Special with internal power unit.Wireless Set No. 20 was an experimental SHF radio link developed in about 1942. Use: Line of Communication high power SHF radio link providing 8 speech channels. Frequency band 7cM. Range 1.3x optical path. RF output 40-150W. Pulse width modulation. Experimental set. Only very few made.Wireless Set No. 21 was a portable transmitter/receiver developed in 1940. Use: Infantry Brigade and RA Regiment communication but later also employed as general purpose ground and vehicle station. Frequency range 4.2-7.5MHz and 19-31MHz. MO control. RF output 0.8-1.5W. R/T, MCW, CW. Range up to 5 miles. Replacing No. 11 Set LP. High band (19-31MHz) hardly used in practice. See also the inside and the transmittersection close up.Wireless Set No. 22 was a portable transceiver developed in 1942. Use: general purpose low power vehicle and ground station with facilities for man pack. Frequency range 2-8MHz. MO control. RF output 1.5W. R/T, CW. Range up to 20 miles. General appearance resemble No. 19 Set. Standard WW2 set. See also the inside.Wireless Set No. 23 was a mobile transmitter developed in 1940. Use: Army Corps and Division communication and later general purpose long-range set. Frequency range 1.12-13.55MHz. MO control. RF output 250W. R/T, MCW, CW. Range 1000 miles. Alternative of No. 3 Set. Limited issue only superseded by No. 33 and 12HP Set. Separate receiver (R101 or R107).Wireless Set No. 24 was an experimental mobile transceiver developed in 1940. Use: short range communication between tanks. Frequency range 230-255MHz. MO control. RF output 0.25W. R/T only. Range up to 3/4 mile. Set was abandoned and function incorporated in 'B' set of No. 19 Set.Wireless Set No. 26 was a mobile multi-channel radio link developed in about 1940. Use: Line of Communication multi channel radio link providing six telephone speech channels. Frequency band 85-100MHz. Crystal control. RF output 65-100W. Range 40-60 miles optical. Set is principally a military version of GPO type system.Wireless Set No. 27 was a man pack transceiver developed in 1940. Use: short range Infantry communication. Frequency range: three spot frequencies 22.5 MHz, 23.5MHz and 24.5MHz; receiver 22-25MHz. Superreg circuit. RF output 0.25W. R/T only. Only very few produced.Wireless Set No. 28 was a man pack transmitter receiver developed in 1940. Use: general purpose Infantry short range communication in forward areas between Company and Battalion HQs. Frequency range 6-9MHz. R/T and CW. MO control. RF output 0.25W. Range 3-5 miles. Limited number produced as an alternative to No. 18 Set.Wireless Set No. 29 was a mobile transceiver developed in about 1945. Use: AFV, tank, truck and ground station. Frequency range 'A' set 2-8MHz; 'B' set 235 and 245 MHz. MO control. RF output 'A' set 25W; 'B' set 1W. R/T, MCW and CW. Range up to 25 miles; 'B' set 3/4 mile. Set was developed in Canada as a replacement of No. 19 Set. Limited number produced. Abandoned.Wireless Set No. 31 was a man pack transceiver developed in 1948. Use: short range communication in Infantry Company and Battalion HQ. Frequency range 40-48MHz. MO control. RF output 0.3W. FM R/T only. Range up to 5 miles. Similar to US Signal Corps SCR-300 (BC-1000) with minor modifications.Wireless Set No. 31AFV was an AFV transceiver. Use: short range communication to Infantry equipped with Wireless Sets No.31 and 88. Frequency range 40-48MHz. MO control. RF output 0.3W. FM R/T only. Range up to 5 miles. The set is basically a modified No.31 Set with a separate 12/24V power pack connected to the vehicle's wireless harnessWireless Set No. 32 was a mobile transceiver developed in about 1944. Use: experimental set to obtain comparisons between AM and FM communications. Frequency range 2-8MHz. MO control. RF output 10 W. R/T (AM and FM) and CW. Range up to 20 miles. Set resembles No. 19 Set and No. 22 Set. Limited production.Wireless Set No. 33 was a mobile transmitter developed in 1941. Use: Line of Communication and general purpose medium-power transmitter, used in a mobile station or ground station. Frequency range 1.2-17.5MHz. MO control. RF output 250W. R/T, MCW and CW. Range up to 80 miles. Set is principally a No. 12 Set with RF power amplifier added. Receiver normally associated is Reception Set R107.Wireless Set No. 36 was a portable transmitter developed in 1941. Use: anti-Aircraft defence gun control communication. Frequency range 10-60MHz. MO or crystal control. RF output 25W. R/T, MCW and CW. Range up to 25 miles. Associated receiver Reception Set R208.Wireless Set No. 37 was a man pack transceiver developed in 1941. Use: short range communication for paratroops. Frequency range 340-385MHz. Super regenerative. RF output 0.5W. R/T and MCW. Range (ground) 1 mile; (ground/air) up to 15 miles. Limited production.Wireless Set No. 38 Mk.II was a man pack transceiver developed in 1942. Use: short range Infantry communication. Frequency range 7.4-9.2MHz. MO control. RF output 0.2W. R/T only. Range: up to 1 mile using long 12ft rod. This set has unique design features using only 5 valves. Standard WW2 set. See also the inside and accessories posted in the gallery.Wireless Set No. 38 AFV was an AFV transceiver developed in 1944. Use: short range communication to Infantry equipped with Wireless Sets No. 38. Frequency range 7.4-9.2MHz. MO control. RF output 0.2W. R/T only. Range: up to 1 mile using long 12ft rod. Principally a MK.II version with a 12V DC supply unit and facilities for control by tank crew.Wireless Set No. 38 Mk.III was a man pack transceiver developed in 1944/5. Use: short range Infantry communication. Frequency range 7.4-9.2MHz. MO control. RF output 0.2W. R/T only. Range: up to 1 mile using long 12ft rod. Basically a tropicalised hermetically sealed version of the Mk.II model.Wireless Set No. 42 was a portable transceiver developed in about 1945. Use: general purpose vehicle/animal pack and man pack station. Frequency range 1.6-12.8MHz. MO control. RF output 10W. R/T (AM and FM) and CW. Range up to 25 miles. Limited trial production. Abandoned.Wireless Set No. 43 was a mobile/fixed transmitter developed in 1943. Use: general purpose high power transmitter for mobile or static operation. Frequency range 2-12MHz. MO/crystal control. RF output up to 400W. Range up to 75 miles as mobile station. Canadian development.Wireless Set No. 46 was a man pack transceiver developed in 1942. Use: principally airborne and sea assault (Commando) troops. Frequency Range 3-9.1 MHz. Crystal control. R/T or MCW. Range: up to 10 miles using long type rod. The first full waterproof man pack set. See also the inside and the underside. Accessories are posted in the Gallery.Wireless Set No. 47 was an experimental semi-portable transmitter receiver developed in 1940. Use: experimental duplex point to point duplex radio link. Frequency 500-550MHz. RF output 5W. MO control. R/T and MCW. Range up to 15 miles line of sight. Abandoned.Wireless Set No. 48 was a man pack transmitter receiver developed in about 1942. Use: short range communication in forward areas within Infantry battalions and RA regiments. Frequency Range 6-9MHz. RF output 0.25W. R/T and CW. MO control. Range up to 10 miles. USA development as an alternative to No. 18 Set. See also the transmitter inside and the receiver inside.Wireless Set No. 49A was a mobile transceiver developed in about 1948. Use: AFV and general purpose communication. Intended as a replacement of No. 19 Set. Frequency range 'A' set 25-38MHz; 'B' set 38-42MHz. RF output 15W; 0.4W. FM R/T. Crystal control. Range 10 miles 'A' set; 4 miles 'B' set. Set comprises two units: WS No. 49A (later C40) and WS No. 49B (later B40). Hermetically sealed. Abandoned and replaced by C42/45 and B47/48.Wireless Set No. 52 was a mobile transmitter receiver developed in 1943. Use: general purpose Brigade to Division communication, principally used as a vehicle or ground station. Frequency range 1.75-16MHz. RF output up to 100W. MO control. R/T, MCW and CW. Range up to 100 miles. Canadian design replacing No. 9 Set. Very successful design.Wireless Set No. 53 was a mobile transmitter developed in about 1944. Use: medium power transmitter primarily for semi-mobile installations such as Armoured Command Vehicles but also used as a ground station. Frequency range 1.2-17.5MHz. RF output 250W. MO and crystal control. R/T, MCW and CW. Range up to 500 miles. Associated receiver is Reception Set R107. Replacement for No. 12HP and No. 33 Set.Wireless Set No. 56 was a mobile transmitter developed in about 1944. Use: high powered jammer and Army chain transmitter. Frequency range 200kHz to 20MHz. RF output up to 12kW. MO control. R/T and various other modulation systems. Communication range world wide. Design abandoned.Wireless Set No. 57 was a mobile transmitter receiver developed in about 1943. Use: auxiliary point to point full duplex service link in No. 26 Set station. Frequency range 85-95MHz. RF output 10W. Crystal control. R/T only. Range up to 60 miles optical range.Wireless Set Cdn No. 58 was a man pack transceiver developed in 1943. Use: short range communication in Infantry Battalion. Frequency range 6-9MHz. RF output 0.3W. MO control. R/T only. Range up to 5 miles. Canadian design as a replacement of No. 18 Set.Wireless Set No. 62 was a portable/mobile transceiver developed in about 1945. Use: general purpose for vehicle and ground station, but suitable as a man pack and animal pack. Frequency range 1.6-12MHz. RF output 1W. MO and crystal control. R/T and CW. Range up to 25 miles. Replacement for No. 22 Set. Accessories and inside view are posted in the Gallery.Wireless Set No. 63 was a transportable transmitter receiver station developed in about 1945. Use: Line of Communication static radio station providing two-way teleprinter operation. Frequency range 3-20MHz. RF output 1kW. MO and crystal control. Tone frequency keying. Range up to 1000 miles. Built into trailer or shelter.Wireless Set No. 68 was a man pack transmitter/receiver developed in 1943. Use: short range communication in forward areas between Battalion HQ and Company HQ. Frequency range 1.75-2.9MHz (WS 68P); 3-5.2MHz (WS 68R and T). MO and crystal control. RF output 0.25W. R/T, CW. Range up to 10 miles. Set is similar to No. 18 Set but with different frequency range.Wireless Set No. 76 was a portable transmitter developed in 1943. Use: light-weight self contained transmitter for rear link communication. Frequency range 2-12MHz. RF output 9W. Crystal control. CW only.Range over 300 miles. Normally used with Reception Set R109. See also the inside.Wireless Set No. 78 was a man pack transceiver developed in about 1945. Use: short range Infantry communication. Frequency range 2.960-9.515MHz. RF output 0.4W. Crystal control. R/T only. Range 3 miles. Limited production. Abandoned.Wireless Set No. 86 was a mobile multi-channel radio link developed in about 1948. Use: vehicular mounted radio relay for communication between Division and Corps. Frequency range 50-100MHz. RF output up to 36W. Crystal control. FM R/T. Range 30 miles optical. Renamed into C41/R222.Wireless Set No. 88 was a man pack transceiver developed in about 1947. Use: short range Infantry Company/Platoon communication. Frequency range 38.01-42.15MHz. RF output 0.25W. Crystal control. FM R/T. Range up to 2 miles. Replacement of No. 38 Set.Wireless Set No. 88 AFV was an AFV version of the No. 88 Set, normally used with Wireless Set No. 19. Frequency range 38.01-42.15MHz. RF output 0.25W. Crystal control. FM R/T. Range up to 2 miles. Replacement of Wireless Set No. 38 AFV.Extensive technical details, comprehensive development history, circuit diagrams, alignment procedures, accessories lists, literature and references, vehicle installation drawings and many, many pictures can be found in "Wireless for the Warrior"Volume 1 and Volume 2.


What is fy 12000 Mhz i found it inside the monitor?

It means that certain components use that kind of electric signal (if it CRT then it is VERY dangerous). 1 hz means one signal per second, 1000 hz (1KHz) means 1000 signals per second and so on. so be very careful with what you touch.It's a 12MHZ CrystalI would agree with Lyzta that you're careful poking round CRT monitors, but I suspect that this is an LCD monitor


What does The device supports throughput of 16 MIPS at 16 MHz mean?

8051 - 8 bit micro based on CISC architecture ( Complex Instruction Set Computer) PIC - 8 bit micro based on RISC architecture ( Reduced Instruction Set Computer)AVR - 8 bit micro based on RISC architecture ( Reduced Instruction Set Computer)there are also 16bit and 32 bit micros from the same familyinvention wise, 8051 is the forefather ( date of birth = 1985), next cam PIC s and then came the AVRs.its essential to learn 8051 to be able to learn other micros. if we come to instruction set of these micros :8051 has 250 instructions which take 1 to 4 machine cycles to executivePIC has nearly 40 instructions which are mostly 4 cycles instructionsAVRs have 140 instructions whcih are mostly 1 cycle basedif we come to speed factor:1 machine cycle in 8051 (normal) divides the clock freq. by 12 ( some derivatives divide by 6 and by 1 also)1 machine cycle in PIC divides the clock freq by 41 M.C in AVRs divides the clock freq by 1for eg: if we use 12 Mhz Xtal in all the 3 micros then the speed of execution will be as follows:8051 = 12Mhz /12 = 1 Mhz i,e = 1 million instructions per secondPIC = 12Mhz/4 = 3 Mhz i,e = 3 million instructions per secondAVR = 12Mhz/1 = 12 MHz i,e = 12 Million instructions per second


What are the features of the Intel 8086?

The main features of 8051 microcontroller are: i. RAM - 128 Bytes (Data memory) ii. ROM - 4Kbytes (ROM signify the on - chip program space) iii. Serial Port - Using UART makes it simpler to interface for serial communication. iv. Two 16 bit Timer/ Counter v. Input/output Pins - 4 Ports of 8 bits each on a single chip. vi. 6 Interrupt Sources vii. 8 - bit ALU (Arithmetic Logic Unit) viii. Harvard Memory Architecture - It has 16 bit Address bus (each of RAM and ROM) and 8 bit Data Bus. ix. 8051 can execute 1 million one-cycle instructions per second with a clock frequency of 12MHz. source : http://www.engineersgarage.com/8051-microcontroller


What are the features fo 'C'?

C Language FeaturesRelocatable Objects / Multiple Compilation Unit*Prior to Version 4, the compile step and linking step were combined, and the user didn't have the ability to compile a unit into a relocatable object to be linked together with other objects. Dividing up your code into several units will not only increase the maintainability of your projects, but it can speed up compilation as only units that have been changed since last build need to be compiled again. Version 4 has several methods of allowing you to create relocatable objects and link them together:Inside PCW, the CCS IDE, you can use the file navigator to add units to your project. When you press Build it will compile all your units and link them together.#import() and #export() preprocessor commands allow you to create units and link units at the source code level./*The following preprocessor command will make the compiler compile this code into a relocatable object file (.o).RELOCATABLE will create a CCS relocatable object file, and is the default format when #EXPORT is used.FILE specifies the name of the output file, and is optional.The ONLY option tells the compiler to only make the symbol GetString (which could be a function or variable) visible to modules that import/link this module.Another option, EXCEPT, has the opposite effect - all symbols except the listed symbols are visible to modules that import/link this module.*/#export(RELOCATABLE, FILE=getstring.o, ONLY=GetString)/*The following preprocessor command will make the compiler link other objects into this unit (in this example it will link unit.o).FILE, ONLY, and EXCEPT have the same operation as detailed in the previous example.COFF is the reciprocal of RELOCATABLE, and tells the compiler to link/import an .o created by MPASM. C18 and C30. COFF can only be used with #import, it cannot be used with #export.*/#import(RELOCATABLE, FILE=unit.o)As shown in the previous examples #import and #export have options for defining scope, but the standard C qualifiers static and extern can also be used for defining scope.Command-line options have been added to create units (instead of a compile/link in one step) and link all units into one final HEX. The following example shows compiling two .C files into separate .O files and then linking them into one .HEX file:C:\project\ccsc +FH +EXPORT main.cC:\project\ccsc +FH +EXPORT uart.cC:\project\ccsc +FH LINK="main.hex=main.o,uart.o"Inside MPLAB&reg; IDE, if you add more than one .C in the project manager all the .C files will be compiled seperately into relocatable objects, and in the final step all relocatable objects are linked into one HEX.* Command-Line compiler customers can only link, they cannot create relocatable objects.Relocatable Objects/Linker functions work only with the CCS C Windows IDE.Generation of multiple hex files for chips with external memoryTwo additional preprocessors are included in Version 4: #export and #import. You have may have already noticed these being used in the above examples for creating relocatable objects, but it has other options for specifying how to export and import HEX files. You will find these commands useful if creating bootloaders or using a device with external memory (CPU or EMCU mode): /*The compiler will create two HEX files. One contains all the ODD addressed program memory, the other contains all the EVEN addressed program memory. You will find this useful if you are using the 16-bit byte write mode on the 18F family external memory interface.*/#export(HEX, file=odd.hex, ODD)#export(HEX, file=even.hex, EVEN)/*When the compiler creates the HEX file for this project, offset all addresses up 0x800 bytes.*/#export(HEX, file=application.hex, offset=0x800)/*The previous example was an application where the final HEX file had it's addresses offset by 0x800. If we wanted to import the loader HEX into the application this could have been done instead:*/#import(HEX, file=loader.hex, range=0:0x7FF)Variable length constant stringsPrior to Version 4, if you had an array of constant strings it was usually inefficient. Examine this example of an ineffecient array of constant strings: const char strings[3][15] ={"HELLO","WORLD","EXTRALONGERWORD"};In the above example we had to make the maximum length of each string be 15 characters because of the length of "EXTRALONGERWORD". But since "HELLO" and "WORLD" are only 6 characters (don't forget null termination), 9 bytes are wasted for each.To alleviate this problem, use this method for variable length constant strings:const char strings[][*] ={"HELLO","WORLD","EXTRALONGERWORD"};Note: this is done by adding extra intelligence to the indexing of the constant data table. Because of this you cannot create a pointer to a variable length constant string.More flexible handling of constant dataVersion 4 has a few ways of allowing pointers to constant data. First, Version 4 adds pointers to constants: /*A simple example showing the assignment of a pointer to a constant with the address of a constant string:*/const char version[] = "PRODUCT ID V1.01";const char *ptr;ptr = &version[0];/*A more complex example that creates an array of pointers to constant strings:*/const char *strings[] ={"HELLO","WORLD","CONST","STRINGS"};/*Access the above const pointers*/const char *ptr;while (i = 0; i < (sizeof(strings) / sizeof(const char *)); i++){ptr = strings[i];printf("%s", ptr);}In addition, constant strings can be passed to functions that are normally looking for pointers to characters:/*The following enables the ability for the compiler to copy constant strings into RAM when being passed as a parameter to a function:*/#device PASS_STRINGS=IN_RAM/*An example of using this new feature:*/if (stricmp(buffer,"ATDT\r")==0){//do something}Note: The const qualifier in CCS always means that the data will be placed in program memory, and that the data is 'read-only'. It does not follow the ANSI definition which simply states that const is 'read-only'.addressmod capability to create user defined address spaces in any kind of memory devicePart of the IEEE Embedded C standard (ISO/IEC TR 18037), addressmod allows you to create custom qualifiers to create variables in any kind of memory device. The identifier can be used with any data types, including structures, unions, arrays, and pointers. Review the following example, which uses addressmod to create variables that are located in external memory: /*Syntax for addressmod is:addressmod (identifier,read,write,start,end)identifier - your new custom identifier nameread/write - the read/write functions to access the external memorystart/end - the range of addresses this identifier can access*/addressmod(extram, readextram, writeextram, 0, 0xFFFF)/*Create a large array, the actual contents of this array will be stored in the external memory.*/extram largeBuffer[2000]/*Create a pointer to the external memory. The pointer itself will be stored in the PIC's memory.*/extram char *extramPtr;/*Some examples of usage*///direct accesslargeBuffer[0] = 5;//assign pointer, get addressextramPtr = &largeBuffer[0];//access external memory indirectly*extramPtr = 5;Function OverloadingVersion 4 has borrowed a C++ feature called function overloading. Function overloading allows the user to have several functions with the same name, with the only difference between the functions is the number and type of parameters. /*Here is an example of function overloading: Two functions have the same name but differ in the types of parameters. The compiler determines which data type is being passed as a parameter and calls the proper function.*/void FindSquareRoot(long *n){/*This function finds the square root of a long integer variable (from the pointer), saves result back to pointer.*/}void FindSquareRoot(float *n){/*This function finds the square root of a float variable (from the pointer), saves result back to pointer.*/}/*FindSquareRoot is now called. If variable is of long type, it will call the first FindSquareRoot() example. If variable is of float type, it will call the second FindSquareRoot() example.*/FindSquareRoot(&variable);Default ParametersDefault parameters have also been borrowed from C++ and have been included in Version 4. Default parameters can be specified in your functions, and if you don't pass the parameter to your function the default will be used. int mygetc(char *c, int n=100){/*This function waits n milliseconds for a character over RS232. If a character is received, it saves it to the pointer c and returns TRUE. If there was a timeout it returns FALSE.*/}//gets a char, waits 100ms for timeoutmygetc(&c);//gets a char, waits 200ms for a timeoutmygetc(&c, 200);Variable number of ParametersYou can use functions with a variable number of parameters in Version 4. This is found most commonly when writing printf and fprintf libraries. /*stdarg.h holds the macros and va_list data type needed for variable number of parameters.*/#include /*A function with variable number of parameters requires two things. First, it requires the ellipsis (...), which must be the last parameter of the function. The ellipsis represents the variable argument list. Second, it requires one more variable before the ellipsis (...). Usually you will use this variable as a method for determining how many variables have been pushed onto the ellipsis.Here is a function that calculates and returns the sum of all variables:*/int Sum(int count, ...){//a pointer to the argument listva_list al;int x, sum=0;//start the argument list//count is the first variable before the ellipsisva_start(al, count);while(count--) {//get an int from the listx = var_arg(al, int);sum += x;}//stop using the listva_end(al);return(sum);}/*Some examples of using this new function:*/x=Sum(5, 10, 20, 30, 40, 50);y=Sum(3, a, b, c);CCS Backwards CompatibilityCCS provides a method to attempt to make sure you can compile code written in older versions of CCS with minimal difficulty by altering the methodology to best match the desired version. Currently, there are 4 levels of compatibility provided: CCS V2.XXX, CCS V3.XXX, CCS V4.XXX and ANSI. Notice: this only affects the compiler methodology, it does not change any drivers, libraries and include files that may have been available in previous versions. #device CCS2 ADC default size is set to the resolution of the device (#device ADC=10, #device ADC=12, etc)boolean = int8 is compiled as: boolean = (int8 != 0)Overload directive is required if you want to overload functionsPointer size was set to only access first bank (PCM *=8, PCB *=5)var16 = NegConst8 is compiled as: var16 = NegConst8 & 0xFF (no sign extension)Compiler will NOT automatically set certain #fuses based upon certain code conditions.ROM qualifier is called _rom#device CCS3 ADC default is 8 bits (#device ADC=8)boolean = int8 is compiled as: boolean = (int8 & 1)Overload directive is required if you want to overload functionsPointer size was set to only access first bank (PCM *=8, PCB *=5)var16 = NegConst8 is compiled as: var16 = NegConst8 & 0xFF (no sign extension)Compiler will NOT automatically set certain #fuses based upon certain code conditions.ROM qualifier is called _rom#device CCS4 ADC default is 8 bits (#device ADC=8)boolean = int8 is compiled as: boolean = (int8 & 1)You can overload functions without the overload directiveIf the device has more than one bank of RAM, the default pointer size is now 16 (#device *=16)var16 = NegConst8 is will perform the proper sign extensionAutomatic #fuses configuration (see next section)#device ANSI Same as CCS4, but if there are any discrepancies are found that differ with the ANSI standard then the change will be made to ANSIData is signed by defaultconst qualifier is read-only RAM, not placed into program memory (use ROM qualifier to place into program memory)Compilation is case sensitive by defaultConstant strings can be passed to functions (#device PASS_STRINGS_IN_RAM)Automatic #fuses configurationVersion 4 configures some of the configuration bits (#fuses) for you automatically based upon your code: By default, the NOLVP fuse will be set (turn off low voltage programming)By default, the PUT fuse will be set (turn on the power-up timer)If there is no restart_wdt() in your code, it will set the NOWDT fuse. If there is a restart_wdt() fuse in your code then it will set the WDT fuse.The oscillator config bits will automatically be set based upon your #use delay() (see next section)If you have the debugger enabled in the PCW IDE, the DEBUG fuse will be set.With the basic #fuses now being set automatically many programs will not need a #fuses directive.This feature can be disabled by using the CCS3 backwards compatability (see previous section).#USE DELAY() ImprovementsCommas, periods and speed postfixes now supported for delay parameterBy using commas, periods and speed prefixes, the delay parameter is now easier to read. The following speed postfixes are supported: M, MHZ, K, KHZ. See the next section for an example.#use delay() has new parameters: OSCILLATOR (or OSC), CRYSTAL (or XTAL), RC (or RC), INTERNAL (or INT)By using these new parameters you can automatically configure your #fuses (configuration bits) for the proper oscillator type and PLL. Here are some examples:/*We are using a 12MHz crystal. This will set the HS fuse:*/#USE DELAY(CLOCK=12MHZ, CRYSTAL)/*We are using an external RC oscillator at 4000345 Hz. This will set the RC fuse:*/#USE DELAY(RC=4000345)/*We are using an external crystal at 10MHz, but because of the HS PLL the actual system will run at 40 MHz. This will set the H4 fuse:*/#USE DELAY(CLOCK=40MHZ, CRYSTAL=10MHZ)/*We are using an internal oscillator at 8 MHz. This will set the INTRC_IO fuse and configure the internal oscillator to run at 8 MHz:*/#USE DELAY(INTERNAL=8000000)#USE SPI()Some of CCS's most powerful libraries have been the RS-232 and I2C libraries, which give users the flexibility of using multiple RS-232 and I2C ports at once using any set of general purpose I/O pins, and not tying the user to only using the hardware peripheral. In Version 4, SPI libraries are included to give the user: use of any general purpose I/O pins, clocking configuration, any number of data bits, streams, clock rate and more! /*The #use SPI configures the SPI port. Here is a simple configuration:*/#use SPI(DO = PIN_B0,DI = PIN_B1,CLK = PIN_B2,baud = 100000,BITS = 8,LSB_FIRST,SAMPLE_RISE,stream = SPI_PORT0)/*Read a byte of data to a 9356 external EEPROM using this new SPI stream*/void Read9356(long address, int data){output_high(EEPROM_9356_SELECT);SPI_XFER(SPI_PORT0, 0x18);SPI_XFER(SPI_PORT0, address);data=SPI_XFER(SPI_PORT0, 0);output_low(EEPROM_9356_SELECT);}#USE RS232() upgradeThe powerful RS-232 library upgrade in Version 4 includes the following options: Two additional parameters to #use rs232(): UART1 and UART2. Choosing one of these parameters will automatically set the transmit and receive pin of the CCS RS232 library to the specified hardware MSSP transmit and receive pins of the PIC&reg; MCU.A timeout parameter is included, which will cause getc() to timeout within specified number of milliseconds.A clock parameter is included, so you can specify the system clock speed instead of using the clock specified in the #use delay. When the clock parameter is not specified, it will use the clock speed specified in the #use delay.The number of stop bits can be defined.You can use RS-232 in synchronous master or synchronous slave.The baud rate option supports commas, periods, and the following prefixes: K, KHZ, M, MHZ. For example, these are now valid: BAUD=9.6k, BAUD=115,200, BAUD=115.2K, etc.#USE I2C() upgradeThe powerful I2C library upgrade has been included in Version 4. First, you can give your I2C ports different stream identifiers. By giving your different I2C channels a stream identifier, it is easier to differentiate in your code which port is being used. Second, the i2c_start() function can send an I2C start or I2C restart signal. The restart parameter for i2c_start() may be set to a 2 to force a restart instead of a start. A 1 value will do a normal start. If the restart is not specified or is 0, then a restart is done only if the compiler last encountered a i2c_start() and no i2c_stop()./*This configures two I2C ports, each has a different stream name.*/#use i2c(sda=PIN_C4, scl=PIN_C3, stream=I2C_HW)#use i2c(sda=PIN_B1, scl=PIN_B2, stream=I2C_SW)/*The following function reads a data byte from a Microchip 24LC16 I2C EEPROM, using the I2C_HW stream*/int Read2416(int address){i2c_start(I2C_HW, 1); //perform a starti2c_write(I2C_HW, 0xA0);i2c_write(I2C_HW, address);i2c_start(I2C_HW, 2); //perform a restarti2c_write(I2C_HW, 0xA1);data=i2c_read(IC2_HW, 0);i2c_stop(I2C_HW);return(data);}Bit ArraysYou can create an array of bits (or booleans). You cannot create a pointer to an array of bits or to a bit. /*This will create an array of bits, and initialize their values*/int1 flags[]={TRUE, TRUE, TRUE, FALSE, FALSE, FALSE};/*Some usages:*/bool = flags[1];if ( flags[2] ) { /* do something */ }flags[i++] = FALSE;Fixed point decimalA powerful feature in Version 4 is the ability to represent decimal numbers using a new data type, the fixed point decimal. Fixed point decimal gives you decimal representation, but at integer speed. This gives you a phenomenal speed boost over using float. This is accomplished with a qualifier: _fixed(x). The x is the number of digits after the decimal the data type can hold. /*Creates a 16 bit variable with a range of 0.00 to 655.35*/int16 _fixed(2) dollars;/*Assign 1.23 to dollars. Internally, 123 will be saved to the int16.*/dollars=1.23;/*Add 3.00 to dollars. Internally, 300 will be added to the int16.*/dollars += 3;/*printf will display 4.23*/printf("%w", dollars);delay_us() and delay_ms() support int16 variable parametersPrior to Version 4, delay_us() and delay_ms() could only take int16 parameters if they were constant values. Version 4 allows you to use delay_us() and delay_ms() with int16 variable parameters. /*This function delays s seconds.*/void delay_s(int s){int16 ms;ms = s * 1000;delay_ms(ms);}General Purpose I/O Improvementsoutput high(), output low(), output toggle() and input() now support variable parametersThe built in functions OUTPUT_LOW(), OUTPUT_HIGH(), OUTPUT_BIT() and INPUT() accept a variable to identify the pin. The variable must have a value equal to one of the constants (like PIN_A1) to work properly. The tristate register is updated unless the FAST_IO mode is set on port A. Note that doing I/O with a variable instead of a constant will take much longer time./*This function gets bit n of port D*/int GetPinD(int n){int16 pin;pin = PIN_D0 + n;return(input(pin));}output_drive()The output_drive() function sets the desired pin's tristate to output. This is the opposite of output_float().get_tris_x()The get_tris_X() function returns the current tristate setting for that port (where X is the desired port, ie get_tris_e())Interrupts ImprovementsThe interrupt_active(INT_XXX) function returns TRUE if the specified interrupt flag is set, meaning the interrupt condition has triggered. INT_XXX is a valid constant, only valid interrupts on your target PIC&reg; MCU are allowed (ie INT_TIMER0, INT_CCP, etc). This will be useful if you want to poll the flag instead of using interrupts. Preprocessor Improvements== and != can be used to evaluate strings at the preprocessor levelThe following example is now legal:#if (getenv("DEVICE") != "PIC16F877A")#error This target PIC is not supported!#endifgetenv() can return byte and bit addresses of special file registersThe getenv() function has two additional options to get the address of special function registers. The strings SFR:name and BIT:name may be used to get the address of a SFR. For example:/*On a PIC16F877A, returns a string of the form 0x003 (where the STATUS SFR is located)*/#byte status_reg = GETENV("SFR:STATUS")/*On a PIC16F877A, returns a string of the form 0x003.0 (where the carry bit is located)*/#bit carry_flag = GETENV("BIT:C")The following parameters to getenv() are available in Version 4:RAM - Returns the number of bytes of RAM the target PIC&reg; MCU has#type upgradedThe #type upgrade defines if the default data type is signed or unsigned. By default the CCS C Compiler uses unsigned.New Peripherals Supportsetup_opampX() - Enable / Disable the integrated operational amplifier on PICmicro&reg; MCUs that have an integrated operational amplifier (see PIC16F785)sleep_ulpwu(us) - Sets the ultra-low power wakeup pin high for the set micro-seconds (which will charge the user's capacitor), then put's the PIC&reg; MCU to sleep. When the capacitor has discharged, the PIC&reg; MCU will awaken (this time is determined by the user's RC time constant). Requires a PIC&reg; MCU with the ultra-low power wakeup feature (see the GP0 on the PIC12F683).Many more example programs and librariesThese are some of the additional libraries and examples included in Version 4: FAT - Access/read/write files on a SD/MMC card that has a FAT file system. Run a long term log on your PIC&reg; MCU, saving each entry by appending to a file. Then read the results on your PC by opening the file.SIM/SMART Card - Access the contact and phone number information on a SIM/SMART card, commonly found on GSM/GPRS cell phones.Frequency Generator - Generate tones, frequencies and DTMF using only one user define general purpose I/O pin. This is done by implementing a software PWM on one pin.XTEA Cipher Library - Transmit encrypted data between two PIC&reg; MCUs using XTEA Encryption.XML Parser - Parse XML documents using the minimal resources of a PIC&reg; MCU.


What are basic features of c?

The C programming model is that the programmer knows exactly what they want to do and how to use the language constructs to achieve that goal. The language lets the expert programmer express what they want in the minimum time by staying out of their .