| ??? 05/11/03 02:10 Read: times |
#45217 - RE: ADuC812 and ADC problem Responding to: ???'s previous message |
Rami Alrz:
You sent me an email with the same question as you posted here. I sent you a reply and yet I still see you asking here. That is no problem but I am also going to post my reply here too for the benfit of the other readers here. Here is the email response I sent you. -------------------------------------- Here are my comments about what you are working on.... 1) You mention that there is a "DAC(0-2)". The reference sheet only shows that there is a DAC0 and a DAC1. 2) When you use the A/D converters I notice that you only are programming values to the ADCCON1 and ADCCON2. This chip also has the ADCCON3 which may be important to initialize too. 3) It is not a good practice to use hard coded SFR addresses in your code. Most all of assemblers include processor specific include files that are to be used. These includes provide names for all of the SFR registers and SFR bits in the bit addressable SFRs. Thus instead of writing.... MOV 0EFH,#07CH ; set ADCCON1 for normal A/D CON. You can write MOV ADCCON1,#07CH ; set ADCCON1 for normal A/D CON. 4) When using the A/D converter you may have to provide initialization for the ADCOFSL, ADCOFSH, ADCGAINL, and ADCGAINH registers. You need to read what these do and decide if they apply to your usage. 5) The A/D converter output consists of data in two bytes. Not just one byte. I suspect that when you read the A/D converter it may actually be necessary to read both ADCDATAL and ADCDATAH. 6) I did not see in your code any provision to synchronize your reading of the A/D converter to the fact that the conversion was complete. Most often software gives a command bit to force a start conversion and then the program code must either delay till the conversion is done or poll some SFR bit that indicates that the conversion is finished. 7) I was very puzzled in your code why you felt it was necessary to access the DAC registers using the MOVX instruction. The DAC1H, DAC1L, DAC0H and DAC1L registers are mapped into the normal SFR memory space. You would access these with direct addressing MOV instructions and not via DPTR and the MOVX opcode. Also note that the D/A converters on this part are more than 8 bits wide and it is most likely that you need to write both a high and a low byte to the D/A to get it to make an output change. If the D/A value was in the registers R3::R2 as high and low bytes respectively maybe this code would work a little better... MOV DAC0H,R3 MOV DAC0L,R2 ....but beware that multi byte outputs to a register pair like this often have a proper order that must be adhered to in order for the D/A update to work correctly. You will need to look at your data sheet to see if the high byte needs to be written first like I show above or if you need to swap the two lines and write the low byte first. 8) When using the D/A converter I see that there is a special DACCON register that may need to be initialized in your code in order to enable and get the D/A converter to function the way you want. You should read about this register in the data sheet and see if it applies to your application. Good Luck Michael Karas PS...Note that I have not worked directly with the ADuC812 part and so my comments are more general in nature and you will have to study the details from the full data sheet and figure out how the part really works. (If you do not already have the full data sheet then you should download it so that you have it. The chart you sent me is a nice quick reference chart but it does not tell many things that are in the data sheet. You can get the full data sheet from this link: http://www.analog.com/UploadedFiles/Datasheets/11291590ADuC812_e.pdf There is also an errata sheet that may be important for you to know about too. You can download that from this link: http://www.analog.com/UploadedFiles/Datasheets/221423551Errata812_f2.pdf MJK |
| Topic | Author | Date |
| ADuC812 and ADC problem | 01/01/70 00:00 | |
| RE: ADuC812 and ADC problem | 01/01/70 00:00 | |
| RE: ADuC812 and ADC problem | 01/01/70 00:00 | |
| RE: ADuC812 and ADC problem | 01/01/70 00:00 | |
| RE: ADuC812 and ADC problem | 01/01/70 00:00 | |
| RE: ADuC812 and ADC problem | 01/01/70 00:00 | |
| RE: ADuC812 and ADC problem | 01/01/70 00:00 | |
| RE: ADuC812 and ADC problem | 01/01/70 00:00 | |
| RE: ADuC812 and ADC problem | 01/01/70 00:00 | |
RE: ADuC812 and ADC problem | 01/01/70 00:00 | |
| RE: ADuC812 and ADC problem | 01/01/70 00:00 | |
| RE: ADuC812 and ADC problem - Hans | 01/01/70 00:00 | |
| RE: ADuC812 and ADC problem - Hans | 01/01/70 00:00 | |
| RE: ADuC812 and, Raghu, Rami | 01/01/70 00:00 | |
| RE: ADuC812 and, Raghu, Rami | 01/01/70 00:00 | |
| RE: ADuC812 and, Raghu, Rami | 01/01/70 00:00 |



