Hi 2 all, Actually iam doing a project where i have to convert the analog voltage to digital and read it's output. I have done the program for generating the sclock and ss/ for ADC(Max187) and getting the serial 12 bit data output successfully.... But iam not able to convert this serial 12 bit data to parallel using 89C51 controller... Can anyone help me by giving some hints or a sample program for it please....
So where, exactly, are you stuck?
Did you check the manufacurer's website for examples & assistance?
What, exactly, have you tried?
What, exactly, were the results?
What debugging have you done to find out why your results were not as you expected?
Debugging tips: www.8052.com/.../120313
See also: www.techonlineindia.com/.../Developing_a_good_bedside_manner.aspx
"getting the serial 12 bit data output successfully..."
once the data is inside the 8051, it is parallel!
Iam getting 12bit serial data output from the ADC, And then iam not geting how to convert this 12 bit serial data to parallel using any of 2 ports of 8051.... Thanks...
If having software SPI, you just toggle the clock for every bit, and pick up the state of the data line once for every bit. Then you use the shift operator to one-bit-at-a-time shift in the values in a 16-bit integer. After all 12 bits have been received, your integer have a value between 0 and 4095 (unless you managed to shift in the data from the wrong direction).
The world is full of examples of software SPI. How many of these examples have you looked at?
I had a logic of reading the data on every negative edge of clock and storing it in A register. As i recieved 8bits i will transfer this data to R0 register and then to B. And then i clear A and read remaining 4bits and mov to port 0,2...
But iam new to this keil programming. So iam not getting how to apply this logic... Thanks...
The shifting of serial bits from SPI to/from a parallel register is no different from shifting any other serial bits to/from a parallel register - so you can use any such example to see how it's done.
There is nothing specific to the 8051 or Keil here - it is all just basic 'C' skills...
Just verify if you do want to transfer 8 bits to one register and then 4 bits to the next register, or if the data is sent in the bit order that you want to do the reverse - receive only 4 bits to the first register before then receiving the remaining 8 bits.
Actually i want just 4MSB bit's of that 12bit serial data to convert into parallel data... Thanks...
Now, why would you select a 12-bit ADC if you only want a 4-bit conversion?
If having 4 bits and full range is 0 to 5V, then each step would represent 0,33V, so one tick up or down is more than the allowed tolerance for the 5V supply. 4 bits would also be unsuitable for measuring battery voltages, unless you don't measure relative to ground but have an offset voltage you measure against.
all you need to do is to write a piece of code that outputs a 12-bit number onto two ports. something like
#define OUT(x) {HIGH_PORT = (x) >> 8; LOW_PORT = (x) & 0x00ff;}
would work in C. HIGH_PORT would be the port where you output the highest 4 bits and LOW_PORT is one for the lowest 8 bits.
you can write fancier ones obviously but that should get you started.
Hi, I can't able to save my program in .hex file. Actually i had written a program but whil iam saving it as .hex file and load the the program it is detecting as Binary but not as Intel Hex file. Can anyone say why iam getting this problem please... Thanks...
"I can't able to save my program in .hex file"
Did you follow the instructions here: http://www.keil.com/support/man/docs/uv4/uv4_ca_createhexfile.htm
"whil iam saving it as .hex file..."
What do you mean by that?
You don't "save it as" a hex file; the build process creates the hex file for you - assuming you configured your project correctly (see above), and that the build completed without problems.
Have you checked that a hex file is created?
Have you checked that it is actually a valid hex file? see: http://www.keil.com/support/docs/1584.htm
"...and load the the program it is detecting as Binary"
What, exactly, is "detecting as Binary" ?
"Can anyone say why iam getting this problem please..."
Not on the description you have provided! You need to take more care to clearly explain pricesely what steps you are taking, what tools you are using, and what results you are seeing.
Remember: nobody knows anything about you, or your project, other than what you clearly describe in your posts! We cannot read your mind; We cannot see your code; etc, etc,...
Do you not have any colleagues, tutors, mentors, or other local support?
Thanks pardon for ur reply... My problem is solved by ur reply post... Thanks very much...
Actually my project is to convert the analog signal input to digital. So for providing the Sclock and SS for Max187(ADC IC) iam using 89c51 IC. This MAx187 will produce 12 bit serial data as output(analog signal which is converted into digital). And i have take that serial digital data output from MAX187 and have to convert agian into parallel data using again same 89c51. Can u send me anycode for doing it please... I have done already a program for it where i can get a digital data from Max187. But iam not getting to convert this serial data to parallel.... Can u help me in this problem also please...
Thanks....