Writting to main memory
Beginer
Posts: 21
Could You help me please with writting to main memory (in assy)? I use assy code to measure severally time delays. Its totally 8 values. What can get I these values into spin language (and then to the second object) ? Originally I wanted use pointer and par register, but this dont me go well. (Ihave got one first value only).
Then crossed my mind to write values direct into some memory cells. I use for this wrlong command, but I get all values equal always. I think that Im writting this way into cog RAM, so not into Main RAM... Also Ihave read warning: "Register cannot exceed $1FF"
Could You tell me how can I solve this problem? What Im doing false? Is it possible, somewhere any examle to find?
ThankYou very much!!!
beginer
Post Edited (Beginer) : 12/28/2009 10:00:42 PM GMT
Then crossed my mind to write values direct into some memory cells. I use for this wrlong command, but I get all values equal always. I think that Im writting this way into cog RAM, so not into Main RAM... Also Ihave read warning: "Register cannot exceed $1FF"
Could You tell me how can I solve this problem? What Im doing false? Is it possible, somewhere any examle to find?
ThankYou very much!!!
beginer
Post Edited (Beginer) : 12/28/2009 10:00:42 PM GMT
Comments
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Keep in mind that the wrlong pasm instruction is the only one (along with wrbyte and wrword) that doesn't follow the "destination,source" operand ordering. It uses "source,destination".
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)
· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
Thanks
beginer
·
When you start the Cog you must give it the address of a Variable main Ram that you want to use as the start of a block of ram to write data to from the Cog.
·
So lets say you have an array in the VAR section called Long DataStore[noparse][[/noparse]50]…..so then you must start the cog and pass it the address of the array.
· okay := Cog := cognew(@StartOfPasmCode,@DataStore) + 1
·
·
Then in you PASM code you must save the passed address (inside Par) to a location in the Cog RAM so as to use it· eg (do this at the beginning of your Pasm code)
·
··········· Mov· StartAddress,Par
·
StartAddress should be defined as a Long or Res· in the Dat section just after the PASM code. You also need to have another Long or Res right after that lets call it ActualAddress.
·
Later when you want to move data to say DataStore[noparse][[/noparse]10] (i.e. the 11th Long) then you would do (assuming the data is in a variable called MyData in the Cog Ram ie. it is also part of the Dat section and is defined as long or res)
········· Mov ActualAddress,StartAddress·············· ‘put start address so as
········· Add ActualAddress,#40·······························‘to increment it by 10*4 (i.e. 10 longs)
········· WrLong MyData,ActualAddress···················‘now write the data to the main Ram
·
You can do the above too with WrByte or WrWord but you then use 10*1 and 10*2 Not 10*4 as the incrementer.
·
Sam
·
·
·
Post Edited (SamMishal) : 12/28/2009 10:46:05 PM GMT
Here is a program that illustrates what I said. It will write the numbers 9 to 0 in an array·in Hub ram
from a Pasm program. A meaningless program but it illustrates the action and the pseudo code I
mentioned above.
Samuel
Post Edited (SamMishal) : 12/28/2009 11:27:15 PM GMT
Ihave corected my code. Program is working however in the same way always. Could You browse my corrected code and tell me, wheather some visible error is in the code ?
It seems, code measure only one first value, the next other are equal. I dont believe, I have false in the function core the program, I think the false is in the writing to memory.
But all it is posible now. I cant find some false. You can change anything in this code and send me it.
beginer
I have 4 optical sensors, and I monitoring time delay between laser's beam coming(arrival) at 2 from 4these sensors. Totally its 16 combinations, some are empty,
because are impossible (jmp#nic). When possiblle kombination is hapenned , the value (dataX=end-begin) are calculated. When next possible combination happened, end value is stored into begin and currently values,flags("soucasny") are stored into old values,flags ("predchozi"). and then are currently values ("soucasny") are zeroing.
Program should continue next... around. I think, idea is visible from code.
Do you see some false? Some errors?
Thanks...
beginer
I will need more time to look at your code....but....from a quick look at it
it appears that your program DOES NOTHING.
All those Pub methods are doing nothing except setting a value to the variables.
Plus you are not even calling them anywhere????
Your PASM code seems to also put values in the variables of the DAT section
BUT.....these are not the same..... HUB RAM and COG ram are two different things.
when the Res Dat variables or the Longs are in the Dat that follows the PASM code,
they become part of the COG RAM...... they are ALSO part of the HUB RAM too.....
BUT.....BUT.... the two are different. When the PASM program is copied to the COG RAM
also the DAT variables that follow are also copied and become part of the Cog RAM, so when
in the PASM program you write data to them that DOES NOT make the same data appear on
the variables of the same name in the HUB ram.
Also when you start the Cog with this line
· okay := Cog := cognew(@Start,0) + 1
YOU ARE NOT giving it an address of any Hub Ram so as to be able to write values to that
area. The zero in red is WRONG.....
Also I do not see HOW you are monitoring any action of the program. All you are doing
is sending some CONSTANT values to the PST and that is it. The Spin program STOPS.
I did not study your PASM code well...... but even if it is doing something I cannot see how you
can VERIFY that ............ your program is ALL JUMBLED.
Have a look at the code I posted and see how you need to pass the address of a HUB variable
to the Cog so that you can use the WrLong to transfer data between the Cog Ram and the Hub Ram.
Also do not think that the variables in the Dat section are the SAME.
The ones in the Hub ram are not the same as the ones in the Cog ram even though they are the same
name.....this is a confusing thing.....that is why you really need a DIFFERENT DAT section for the
PASM and the SPIN variables.
If you can explain in WORDS (I know English is not your language but try) what you WANT to do
maybe we can help more.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Samuel
www.robotbasic.com
Post Edited (SamMishal) : 12/29/2009 6:22:18 PM GMT
I can sort of see what you have done.....you have HARD CODED the addresses in the Hub Ram
where you want to copy data from the Cog to the Hub......BAD programming.....but OK I will
accept that and accordingly suggest a correction for the Main method so as to get it "working"
See new program below......
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Samuel
www.robotbasic.com
Post Edited (SamMishal) : 12/29/2009 6:19:42 PM GMT
I also noticed that you are using the WRONG methods for the Serial object....here is the new
Main method that outputs correctly to the PST
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Samuel
www.robotbasic.com
Post Edited (SamMishal) : 12/29/2009 6:17:17 PM GMT
I Have a look at the code what you posted me, I tryied start the program with this configuration, but program are functionless. So I try it this way.
Re: 16 combinations, it looks like you only have 4 valid cases (and 12 impossible ones). Why don't you just ignore the impossible cases, i.e. do the 4 valid checks and ignore the rest? There is really no point evaluating every single one.
As for measurements, it seems you are better off looking at all 4 sensors at the same time, then - when one (or more) of them changes - take action (e.g. start timer). Then wait for the next change etc. How is beam arrival indicated anyway, low or high?
- catch event on sensor A
- catch event on sensor B (could be the same as A)
- make some decision regarding order, write some data
It seems that only two sensors are sampled anyway. Is that on purpose/work-in-progress?An active sensor is represented by 1, inactive by 0. Furthermore, lets say the activation sequence is AABB (looped). This gives us all 4 transitions (AA, AB, BB, BA) and should therefore result in all 4 data locations being written to. Your decision making code looks like this (cut down for 2 sensors).
Now let's assume that sensor B was activated twice. This means Ap/As are 0 and Bp/Bs are 1. And that's where the problem is. Comparing Ap to As will set the Z flag despite both being zero (inactive). I think what you actually want here is a test which sets a flag only when both Xp and Xs are 1, e.g.
With that modification and a sensor cog - which generates the AABB sequence mentioned above - I am able to exercise all 4 data write paths in your code (prekmitP/L, volnobehPL, volnobehLP).
thanks
With soucasnyPh inactive (0) you'll end up at next3 (Z set, C set). If it's active (1) the first check makes a decision based on C which is undefined, so you may or may not jump to next3. As soucasnyPh is 1 all the other sensors are 0 which means the second check will set Z and therefore jumps to next3 again. Which means if predchoziPh is inactive your evaluation stops here. End of line.
From what I gather from your latest source file you want something like this (predchozi??/soucasny??, both active):
- Ph/Ph: prekP
- Ph/Pv: rychPL_P
- Lh/Lh: prekL
- Lh/Lv: rychLP_L
- Pv/Ph: rychLP_P
- Pv/Lv: volnoPL
- Lv/Lh: rychPL_L
- Lv/Pv: volnoLP
So why don't you simply check those 8 cases and if they don't apply then fall through to next3? For example:Also, all long in your DAT section must be defined BEFORE any res.
Post Edited (kuroneko) : 1/8/2010 2:57:26 AM GMT