Some one take a look at this and tell me if it's right
James Long
Posts: 1,181
I took this directly out of the MAX_1270 file. The pub start and the·get_count parameters do not match. Is this common?
The reason I ask.....I do not see where the control & control_bit have any correlation. Nor the average & averag_sample.
This has been cracking my skull for at least two days. I have a max 1202 which has the basic same communication structure....but I can't seeme to get the chip to communicate using this object. Before you ask...I checked the control byte (from the MAX 1202 PDF)to make sure I'm putting in the right configuration. My confusion comes from the difference of the parameters.
Any help you guys can shed will help.
James L
pub start(control,average,ADC_addr)
· cognew(get_count(control,average,ADC_addr),@stack1)
·
·············
pub get_count(control_bit, average_sample, ADC_count_address) | temp, adresult_temp
·· repeat
····· adResult_temp := 0
····· repeat average_sample
······· delay.pause1ms(10)····························· ' wait 10 msecond···
······· outa[noparse][[/noparse]CsAdc] := 0······························· '' signal chip select
·····
······· bs2.SHIFTOUT(AoutAdc, ClkAdc,control_bit, BS2#MSBFIRST,8 ) '' put the control bit out
······· outa[noparse][[/noparse]CsAdc] := 1············································
······· outa[noparse][[/noparse]CsAdc] := 0
······· temp := bs2.SHIFTIN(AinAdc, ClkAdc, BS2#MSBPRE,12)········ '' data in
······· adResult_temp := adResult_temp + temp
······· outa[noparse][[/noparse]CsAdc] := 1
···
····· long[noparse][[/noparse]ADC_count_address] := adResult_temp / average_sample······················ ' average samples
Post Edited (James Long) : 9/17/2006 7:51:14 PM GMT
The reason I ask.....I do not see where the control & control_bit have any correlation. Nor the average & averag_sample.
This has been cracking my skull for at least two days. I have a max 1202 which has the basic same communication structure....but I can't seeme to get the chip to communicate using this object. Before you ask...I checked the control byte (from the MAX 1202 PDF)to make sure I'm putting in the right configuration. My confusion comes from the difference of the parameters.
Any help you guys can shed will help.
James L
pub start(control,average,ADC_addr)
· cognew(get_count(control,average,ADC_addr),@stack1)
·
·············
pub get_count(control_bit, average_sample, ADC_count_address) | temp, adresult_temp
·· repeat
····· adResult_temp := 0
····· repeat average_sample
······· delay.pause1ms(10)····························· ' wait 10 msecond···
······· outa[noparse][[/noparse]CsAdc] := 0······························· '' signal chip select
·····
······· bs2.SHIFTOUT(AoutAdc, ClkAdc,control_bit, BS2#MSBFIRST,8 ) '' put the control bit out
······· outa[noparse][[/noparse]CsAdc] := 1············································
······· outa[noparse][[/noparse]CsAdc] := 0
······· temp := bs2.SHIFTIN(AinAdc, ClkAdc, BS2#MSBPRE,12)········ '' data in
······· adResult_temp := adResult_temp + temp
······· outa[noparse][[/noparse]CsAdc] := 1
···
····· long[noparse][[/noparse]ADC_count_address] := adResult_temp / average_sample······················ ' average samples
Post Edited (James Long) : 9/17/2006 7:51:14 PM GMT
Comments
The fact that you have control in one routine and control_bit in another or average in one routine and average_sample in another, while confusing, doesn't matter.
So what relevance·does the·"·
pub start(control,average,ADC_addr)
· cognew(get_count(control,average,ADC_addr),@stack1
have to do with anything. I can find no declarations for these. I don't see what purpose they serve. There are no variables or constants assigned to them. Maybe I'm not asking right.
I see no need for these parameters as named. If there is a need I can't see it. I understand the parameters are there for a reason, but there seem to be no active method to act on these parameters, as they are named.
I hope that makes sense,
James L
I uploaded the file for you to be able to check and tell me I'm wrong. I assume I'm missing something....or just out in left field.
Post Edited (James Long) : 9/17/2006 10:33:20 PM GMT
Whenever there's a subroutine (method) call in SPIN, a stack
frame is set up by the interpreter. This contains the return
address, the address of the caller's stack frame, a long for the
result value, and one long for each parameter of this call.
The result value is always initialized to zero and the parameters
are effectively initialized to the values (in order) presented in
the call. Any local variables are allocated in order in the stack
frame after the last parameter.
I hope this hasn't confused things further.
Mike
What if there are no declarations for control,average, or ADC_addr?
my problem is this is not my code.....I'm using it from the object exchange. There are no VAR or CON statements for these parameters.
I know I could pass along parameters from my top object file....but I don't see the reason to do so.
I will include the init of the I/O as yopu suggested.
JamesL
Mike