Home
Application Note 141 Controlling a DS1804 Using an 8051
Contents
1. set GIE clir set Sect Tet b b b Increment1804 UnD nCS ninc nCS ninc select increment select chip set nCS before nInc to Ne Ne Ne Ne Ne Ne 8ofll clear inc increase to next position avoid writing to the NV EEPROM register in the DS1804 set niInc back to inactive state AN141 Ne Ne e Ne Ne Ne Ne Ne Uses no other routines Decrement Decrements the chip b n decrements UW nonvolatile regist M Ne Ne Ne Ne Ne Ne Decrement18 Uses no ot clr cule Gurr Se Sel rel tb withou U n n n Decrement18 clr UnD clr nCS eux ninc setb ninc ele ninc setb ninc cir ninc setb ninc clir ninc setb ninc CLr ninc setb ncs setb ninc ret Decrement Decrements Ne Ne Ne Ne Ne Ne Ne Ne Ne Ne Ne Ne Ne Ne er Ck CK CK KK KKK KKK KKK KK KK KKK KK KKK KK KKK KKK KK KKK KK KKK KKK S KG AG AR koX DS1804x5 Routine the chip 5 times without de selecting the
2. This does not write to the select increment select chip clear inc ninc in ninc in set ninc in ninc in 6 6 6 6 the set 1 time 04 nD CS Inc CS Inc t writing to ther routine Ne Ne Ne Ne Ne Ne back back back back CS before n NV EEPROM regis ninc back to inact increase to inact crease to inact crease to inact crease to in crease in in in in and de select the nonvolatile register to n to n to n to n active to n nc to avoid wri and destroys no registers bE KKK KK KKK KKK KKK KKK KKK KKK KKK KEKE KKK KKK KKK KKK KKK ck ck ck ck ck ck ck ck ck kkkkkkkk 04x5 ext pos state ext pos state ext pos state ext pos state ext pos tive tive tive a a ter in the tive state S sel select chip clear inc set nCS before n the NV EEPROM regis ct decrement decrease set nlInc back to inact 91 and destroys no registers to next pos nc to avoid wri ter in the tiv
3. D UNE Wait 1 6 us Function URS DUAE Wastes 1 6us of processor time with call nop and return KEK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK ck ck ck ck ck KKK KKK KKK Ne Ne LO Requires no other routines or registers X A ke KK A Kk KR ko ko koX CK CK CK KK KKK KK KKK KK KKK KKK KK KKK CK Sk C S A waitl6us nop 1 nops 4cc each lcall 16cc ret 16cc produces approximately 1 6us of delay with a 22 22MHz clock ret END End of program 11ofll
4. DS databook If interrupts are to be tialized here i oe KKKKK CK C CK CC CC KKK KK KKK KKK KKK KKK KKK KK KKK KKK KKK KK KKKKKKKKKKKK No T nabled they n org 0000h ljmp start org 0003h ljmp start org 0008 ljmp start org 0013h ljmp start org 0018 ljmp start org 0023h ljmp start org 002Bh ljmp start org 0033h ljmp start org 003Bh ljmp start org 0043h ljmp start org 0048 ljmp start org 0053h ljmp start org 005Bh ljmp start org 0063 ljmp start org 006Bh ljmp start Power up and Reset External In Timer 0 Int External In Timer 1 Int Serial Port Timer 2 Int PowerFail Serial Port 1 In terrupt 0 errupt terrupt 1 errupt 0 Interrupt errupt nterrupt DS Priority 1 terrupt DALLAS terrupt 2 DALLAS terrupt 3 DALLAS External In External In External In External In Watchdog In terrupt 4 DALLAS terrupt 5 DALLAS terrupt DALLAS Real Time Clock DALLAS 61 AN141 KKK KK KKK KK KKK KK KKK KKK KKK KK KK KKK KKK KK KKK KKK KK KKK KK KKK P The Main Program demonstrates using a 8051 to c
5. ak Window 0 RO Used as scratch pad destroy with caution Window 0 R5 R7 Used for timer scratch pad destroy with caution AB BK WEN RRA US ORO REER BRB AB epo oe eee ub sevo e oae uve BRS ERER EKRE BRK eo RRL Sinclude c firmware reg520 inc SFR register defs for compiler IM I EI E Variable Declarations Ck ckckckck ck kck ck ck k General Variables stack equ O2Fh bottom of stack stack starts at 30h EEEE AR RE RARER SFR Declarations General SFR Names smod 1 equ ODFh buad rate doubler bit declared 5ofll AN141 PUN Port J Signal LED RX1 TX1 ninc UnD neS eq eq eq eq eq eq Names 90h 92h 93h 94h 95h 96h P1 0 is LED P1 1 is not used P1 2 is Serial Port RX P1 3 is Serial Port 1 TX P1 4 is not Inc 1804 P1 5 is Up not Down 1804 P1 6 is not ChipSelect 1804 P1 7 is not used ew Hardware 7 Interrupt Vectors Table on page 95 of label Interrupts are enabled in this code d to have the ini
6. set nCS before nInc to Ne Ne Ne Ne Ne Ne Ne Ne Ne Ne Ne Ne Ne Ne clear inc increase to next position set nlInc back to inactive state clear inc increase to next position set nlInc back to inactive state clear inc increase to next position set nlInc back to inactive state clear inc increase to next position set nlInc back to inactive state clear inc increase to next position the NV EEPROM register in the DS1804 set niInc back to inactive state avoid writing to Increment Incremen ts DS1804 Routine the chip 1 time and de selec without wri ts the chip ting to the nonvolatile regis Cers ARRE Ck CK C Ck Ck KC CK CC SCC CK CC CK CSS KC CC KC CK S Sk S A KK A Kk KK A Kk AR ko ko RR Uses no ol ther routines and destroys no registers
7. P1 0 is the second Functioning as a status indicator in the program the LED is toggled intermittently to show that the program is still executing 251804 Ycc cs D587C520 DS1075_66 170 OSCIN 3 ETAL HNC VCC OE s PDN GND ELX Figure 1 Schematic Showing the DS87C520 DS1804 and DS1075 Connections The DS1075 can be replaced with a 22 118 MHz crystal Instructions for operating the DS87C520 with a crystal clock source are available in Dallas Semiconductor s High Speed Microcontroller User s Manual It should be noted that the DS87C520 is capable of operating with up to a 33 MHz clock however the delays used in the software depend upon the clock frequency Operating the DS87C520 at a higher clock rate can potentially cause timing faults with the DS1804 while operating at a lower frequency should have no ill effects lof 11 031201 AN 141 Using the CS INC and UD Signals to Control the DS1804 Operation of the DS1804 is simple but a couple of nuances need to be understood for reliable operation First the device powers up over the course of 50ms Attempts to signal information to the part before that period of time elapses will not be successful The part also requires 500us to adjust the value of the wiper to the value stored in the non volatile register during power up After power up there are two ways to increment or decrement the part The first method only changes the value of the potentiometer wiper position The s
8. NN MEINEN IIT NUMINE Application Note 141 E DALLAS Controlling a DS1804 Using an 8051 E SEMICONDUCTOR Compatible Microcontroller Introduction The DS1804 Nonvolatile NV Trimmer Potentiometer is ideal for use in any system that requires a biasing voltage current or resistance with or without manual adjustments Its increment decrement interface allows either the use of minimal external hardware for manual adjustments or a microcontoller for autonomous operation The wiper can be adjusted to one of 100 positions and any value can be stored in the part s NV register to select the wiper value at power up The part also offers several small packaging options including 8 pin DIP SOIC uSOP and flip chip packages This application note provides a simple hardware and software set up for controlling the DS1804 with a Dallas Semiconductor DS87C520 8051 Microcontroller Hardware Setup for Microcontoller Communication with a DS1804 One of the primary benefits of using a DS1804 is the simplicity of the hardware and software control interface Only three connections are required between the potentiometer and the microcontroller chip select up down select and increment which are on pins P1 6 P1 5 and P1 4 of the microcontroller in Figure 1 respectively Two additional components for supporting the 8051 program are shown on the schematic The first is a DS1075 EconOscillator chip that provides a 22 22 MHz clock for the 8051 an LED attached to
9. Site www dalsemi com Ordering Information www dalsemi com products ordering pdf FTP Site ftp ftp dalsemi com Datasheets www dalsemi com datasheets pdfindex html Package Mechanical Drawings www dalsemi com datasheets mechdwg html 4ofll AN141 Appendix A 8051 Software Used to Communicate with the DS1804 DS87C520 APPS DEVELOMENT SYSTEM Application Communication with a DS1804 SS Software Revision History eck F 1 0 02 07 01 First try at operating a DS1804 using the e generic application engineering generic 8051 es boot loading board ax Hardware Description 7 7 Pe Pee BED P0 0 SN74F373N OE OP gle POLL P1 2 RXD1 Not used P0 2 P1 3 TXD1 Not used PQ 3 P1 4 nInc POLA P1 5 UnD 20 5 5 PVG nos P0 6 xs A ee PO yc 1 EK P3 0 RXDO Not used P2 0 Upper P3 1 TXDO Not used P2 1 Address PY P3532 gt P2 2 Byte P SPB 3 S ae ESSA P2 4 Q o 315b B2 5 P3 6 WR P2 6 P3 7 RD P2 7
10. at could be used for adjusting the wiper position and writing to the NV register of a DS1804 however the easiest method requires only four routines These routines initialize the DS1804 increment the chip one wiper position decrement the chip one wiper position and write the current wiper position to the NV register These routines are provided in Appendix A and are called Init1804 Increment1804 Decrement1804 and WriteNVreg The Increment1804 and Decrement1804 routines can be placed in a loop to in decrement the DS1804 n times and once the desired wiper location is reached it can be written to the NV register by calling the WriteNVreg routine If it is desirable to in decrement the DS1804 n times without writing the loop in the main program a short routine could be written that receives n from the stack or the accumulator and implements the loop s function The downfall of using only four functions occurs when the overhead of selecting Up Down and CS during each adjustment slows operation down too much for the application at hand Thus two additional functions are included that demonstrate in decrementing the chip five intervals each way with a single selection both the direction and chip select inputs These routines are called Increment1804x5 and Decrement1804x5 2 il AN 141 In addition to the routines described above three other routines reside in the software to generate timing They are called waitl6us wt and wait3sec These f
11. e state ting DS180 ition ition ition ition ition ts the chip ition ting to DS1804 kck Ck CK CK Ck Ck KC CK CK CC CCS CC CC CK SCC CK SCC CK CK CC CK C Sk S A S A Kk KK A kx AR Kk Kk X DS1804 Routine the chip ARRE Ck CK CK Ck Ck KC CK CC CK C CK CC KKK KKK CK CK KC CK CK C Ck S S A KK A Kk KK KA Kk AR ko ko koX AN141 oe KKKKK KK KKK KKK KK KKK KK KKK CK KK KKK KKK KKK KKK KK KKK KK KKK S koX Sagi DS1804 Write Nonvolatile Register Routine eT perry Writes the Nonvolatile Register to the current wiper Te NUS ja SN value and then waits 1025 for the write to occur EREE Uses wt routine and destroys registers R5 R6 and R7 A ER Ql Cu S EIC C C PE EE WriteNVreg CLE ncs select chip setb nCS deselect chip nInc already high so the DS1804 will store to the NV Register wait 10ms before continuing the NV Reg storage
12. econd changes both the value of the wiper and writes the current value to the non volatile register Changing the wiper position without writing to the non volatile register is accomplished by the following Adjust the up down select input to high for increment or low for decrement Enable the chip by asserting the CS signal active low Pulse INC low n J times to in decrement the part n times Assert INC low again the part in decrements one more time on the falling edge of INC Disable the chip by de asserting CS De assert INC to complete the write Qv lS To change the value of the wiper and write the final wiper position to the nonvolatile register complete the following sequence Adjust the up down select input to high for increment or low for decrement Enable the chip by asserting the CS signal active low Pulse the increment signal low n times to in decrement the part n positions Disable the chip by de asserting CS Wait 10ms for present wiper position to be written to NV register ph eU pales Another simple useful routine stores the current value of the wiper position into the NV register Pulsing CS low while increment remains high stores the current value of the wiper into the NV register After CS is de asserted the controller should wait for 10ms to elapse for the NV register to be written with the present wiper position 8051 Software for Controlling a DS1804 There are millions of different routines th
13. gister was previously written then it will display that value otherwise it will display the pseudo random value stored in the NV register by the factory before shipping The wiper output will display the voltage on the multi meter that corresponds to the value stored in the NV register for 3 seconds The output will then incremented in 0 25V steps and hold each value for 3 seconds before moving on to then next position This will occur five times for a total voltage change of 1 25V The wiper voltage will then be lowered 0 25V and that value will be held for 3 seconds This value will be stored in the NV register and will be the value that the part boots up to the next time power is cycled Finally the wiper voltage will be incremented 0 05V and then decremented 0 05V with both values being held for 3 seconds The LED attached to P1 0 will be toggled every 3 seconds directly before every change occurs In the event that the chip powers up with a wiper value equal to or greater than 3 76V the program will attempt to increment the chip past 5V This does not damage the part but the output will remain at 5V until a decrement command is issued Thus the end voltage in this case would be 4 75V 3011 AN 141 Dallas Semiconductor Contact Information Address 4401 S Beltwood Parkway Dallas TX 75244 Tel 972 371 4448 Fax 972 371 4799 Product Literature 972 371 4448 Sales and Customer Service 972 371 4969 World Wide Web
14. ommunicate with a DS1804 The program increments and decrements the P potentiometer without writing the NV Register and it ot x demonstrates writing to the NV Register as well RRR org 0080h location that hardware begins execution start after a reset clr EA Disable Interrupts cpl LED Complement LED Identifies that the gt program has started execution lcall init1804 initializes DS1804 must be done in first 50ms to avoid the three inputs becoming active without them being in a known state lcall wait3sec give time to read the last NVReg value on a multimeter cpl LED toggle LED mov RO 5 increment the 1804 by 5 intervals 5 times loop10 i with 3 seconds between increments lcall Increment1804x5 increment the DS1804 lcall wait3sec waits 3 seconds cpl LED toggle LED djnz 50 0 lcall Decrement1804x5 decrement the 1804 5 intervals cpl LED toggle LED lcall WriteNVreg write current value to NVReg Now 20 steps i greater that the start of execution cal wait3sec wait 3 seconds for multimeter use cpl LED complement LED lcal Increment1804 increment 1804 once don t write NVReg cal wait3sec wait 3 seconds for multimeter use cpl LED Complement LED lcal Decrement1804 decrement 1804 once don
15. t write NVReg cal wait3sec wait 3 seconds for multimeter use cpl LED Complement LED EndOfMain wait forever sjmp EndOfMain Tofil AN141 Ne Ne Ne Ck CK CK CC CC SCC CK 2 CC CK SCC CK C CK CK C C Sk S S Kk A koX Uses no other routines Increment Incremen the chip be ts DS1804x5 Routine the chip 5 times without de selecting the tween increments This does not write to the nonvolatile register KEKE KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KEK KKK KKK KKK KK KKK KKK ck ck ck ck ck ck KKK KKK KKK and destroys no registers ERR set CILE eux set Cir b Increment1804x5 UnD Q Set clr set clir set CLIE set Sel ret ct SoS B Et Se De 5 Q00000000 select increment select chip
16. time mov R5 4255 mov R6 3 mov R7 1 lcall wt ret M Ne Ne Ne Ne Ne Ne Ck CK C C CK CC CK KKK KKK KK KKK KKK KKK KKK KKK KKK KKK KKK KK KK KKK KK KKK KK KKK KK KM A Kk AR ko RRR Initialize 251804 Routine NBN KEAR Sets all three control signals to their inactive state KERA EEEE and waits 50ms for the inputs to become active before KERE WORK A returning to the main program SEIS Rut 7 Uses wt routine and destroys registers R5 R6 and R7 T KEK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KEKE KKK KEKE KKK KKK ck ck ck ck ck ck ck ck ck kk kkkk kk init1804 Ne Ne Ne Ne Ne Ne Ne Ne setb nCS de select 1804 setb nInc de activate Increment Signal setb UnD Select increment wait 50ms this is done so communication will not begin before the DS1804 is ready to accept input mov R5 4255 mov R6 15 mov R7 41 lcall wt ret M Ne Ne Ne 9 RRR RRR RR ALOR KREDI K KER AR RR RR RR EDEN KOROK OK BR RED RR RR BER EER KON KON GEO RR RRR LR BERBER KORR ORC PEREN Wait 3 Seconds Function Baye QUUM PERSON S Muse GI Ane S ele Rec FIO we epe 2 2 2 2 aN 21 2 12121212121 1 IN Mey Raters igs ex tob 2 2 Ie UNE RS pr requires wt routine and destroys R5 R6 and R7 E RAR LEBEL BR BABB BR BRB RRS BR BER ex eoe BR RRB RRR LER BR BRB LER BRL RB RRR BRB wait3sec mov R5 4255 mov R6 147 mov R7 46 lcall wt ret wait 3 sec this is done so ad
17. unction provide a fixed 1 6us delay a variable delay that is selected by the values stored in R5 R6 and R7 and a fixed 3 second delay that is used in the main program Main Program Sequence Disables all interrupts 2 Toggles LED on P1 0 to signify beginning of execution 3 Initializes the DS1804 by setting all three DS1804 inputs high and waiting 50ms 4 Waits 3 seconds toggles LED The 3 second delay allows the power up value of the DS1804 to be read with a multi meter and the LED indicates when changes are occurring 5 Increments the DS1804 in 5 interval bursts a total of 25 positions A 3 second pause has been added between each of the 5 interval bursts to allow a multi meter to monitor the changes The LED will toggle as the changes to the wiper occur 6 Waits 3 seconds toggles the LED and decrements the DS1804 5 intervals 7 Writes the NV register to the current value 8 Waits 3 seconds toggles the LED and increments the DS1804 1 interval 9 Waits 3 seconds toggles the LED and decrements the DS1804 1 interval 10 Completes execution with an infinite loop Main Program Output Assume that you are executing the program with Vcc at 5V with a 22 MHz crystal a multi meter is connected between W and Gnd and cycling Vcc from Gnd to 5V starts the program The output of the DS1804 will be as follows When power is turned on the part will boot up to the value last stored in the NV register If the value of the NV re
18. vances can be watched on a multi meter Ne Ne Ne Ne 10of 11 AN141 KKK KK KKK KK KK KKK KKK KKK KK KKK KKK KK KKK KKK KKK KK KKK KK KKK KKK BIRAKA General Wait Function KARKR POETE KK Can wait anywhere between 14 42us to 221 sec EE SR ERK Waits R7 867 6 ms if R5 R6 255 BRN PAKER Waits R6 3 4 ms if R5 255 and R7 1 REKK DARRER Waits R5 13 34us if R6 R7 1 KRKK IE KERN EAN N ERR NN NEA REN AS A RREN NERE KAA AE E E KNA oN P requires 731816115 routine 5 a destroys R5 R6 and R7 registers PE dir di dir di di dir di dir dir di diri dio ir di ir dio ir di iri di rdi dir di ir i io ir di ird dio rdi irr dio ir di ir dio i dir dio d rd o ir di ir di rdi di di wt lcall waitl6us 12 8us of waits lcall waitl6us lcall waitl6us lcall 21215 lcall 21215 lcall waitl6us lcall waitl6us lcall waitl6us djnz R5 wt Wait R5 13 34us 1 1115 if R6 R7 1 djnz R6 wt Wait R6 3 4ms if R5 255 R7 1 djnz R7 wt Wait R7 867 6ms if R5 R6 255 ret
Download Pdf Manuals
Related Search
Related Contents
Rotary Hammer Bohrhammer Młot obrotowy Be=eNerve 取扱説明書 - 株式会社ホーマーイオン研究所 Ruedas Libres de la Serie ZZ E08.697s Controlador N1040 - NOVUS Produtos Eletrônicos Sony FDA-A1AM Operating Instructions INSTALLATION MANUAL FOR JABIRU 3300 AIRCRAFT ENGINE Copyright © All rights reserved.
Failed to retrieve file