| Details |
Message |
|
Read-Only
Author Ejaz Shaik
Posted 1-Jun-2011 09:56 GMT
Toolset C51
|
 Need some help in programming 8051 with keil C
Ejaz Shaik
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....
|
|
|
Read-Only
Author Andrew Neil
Posted 1-Jun-2011 10:27 GMT
Toolset None
|
 RE: iam not able to convert this serial 12 bit data to parallel
Andrew Neil
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: http://www.8052.com/faqs/120313
See also:
http://www.techonlineindia.com/article/09-09-23/Developing_a_good_bedside_manner.aspx
"getting the serial 12 bit data output successfully..."
once the data is inside the 8051, it is
parallel!
|
|
|
Read-Only
Author Ejaz Shaik
Posted 1-Jun-2011 10:44 GMT
Toolset C51
|
 RE: iam not able to convert this serial 12 bit data to parallel
Ejaz Shaik
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...
|
|
|
Read-Only
Author Per Westermark
Posted 1-Jun-2011 11:46 GMT
Toolset C51
|
 RE: iam not able to convert this serial 12 bit data to parallel
Per Westermark
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?
|
|
|
Read-Only
Author Ejaz Shaik
Posted 1-Jun-2011 11:54 GMT
Toolset C51
|
 RE: iam not able to convert this serial 12 bit data to parallel
Ejaz Shaik
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...
|
|
|
Read-Only
Author Andrew Neil
Posted 1-Jun-2011 11:56 GMT
Toolset None
|
 RE:The world is full of examples of software SPI
Andrew Neil
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...
|
|
|
Read-Only
Author Per Westermark
Posted 1-Jun-2011 12:56 GMT
Toolset None
|
 RE:The world is full of examples of software SPI
Per Westermark
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.
|
|
|
Read-Only
Author Ejaz Shaik
Posted 1-Jun-2011 13:01 GMT
Toolset None
|
 RE:The world is full of examples of software SPI
Ejaz Shaik
Actually i want just 4MSB bit's of that 12bit serial data to
convert into parallel data...
Thanks...
|
|
|
Read-Only
Author Per Westermark
Posted 1-Jun-2011 13:10 GMT
Toolset None
|
 RE:The world is full of examples of software SPI
Per Westermark
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.
|
|
|
Read-Only
Author Ashley Madison
Posted 1-Jun-2011 16:17 GMT
Toolset C51
|
 RE: Need some help in programming 8051 with keil C
Ashley Madison
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.
|
|
|
Read-Only
Author Shaik Ejaz
Posted 7-Jun-2011 09:59 GMT
Toolset C51
|
 RE: Need some help in programming 8051 with keil C
Shaik Ejaz
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...
|
|
|
Read-Only
Author Andy Neil
Posted 7-Jun-2011 10:32 GMT
Toolset C51
|
 RE: Pardon??
Andy Neil
"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?
|
|
|
Read-Only
Author Shaik Ejaz
Posted 7-Jun-2011 10:57 GMT
Toolset C51
|
 RE: Pardon??
Shaik Ejaz
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....
|
|