We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hello, i am new here and asking for help to do this: i use an LPC2132 and need to read the output of an analog sensor that gives 0,3v-3,2v and on other AD port read the voltage of an 12v battery, the only thing that i know is that i have to make an voltage divider for the bat. can anyone help me with some example to result in a function like "volts=read_ad(port_x)" thanks in advance for your help
I do not know your processor specifically, you will need to consult the data sheet to get the specifics. What I have here is information from the LPC2300 series. Again, YOU will need to consult YOUR data sheet for YOUR processor.
you will want to have a routine to initialize the ADC system. You'll want to power on the subsystem, select the appropriate modes for the input pins you are using, and set up the subsystem for the way that you are going to use it.
A read_ad function can start a conversion, wait for it to complete, and return the data. Again, consult your data sheet for the registers to read and write to start conversion, read status, etc.
If you haven't figured it out yet, let me be more clear: Read the data sheet, it has all of the answers you need. Well, most of them anyway. When you find something that you can't figure out from the datasheet, come back with specific questions.