ICCPROP and cognew_native
Ward
Posts: 4
I am new to the Propeller and ICCPROP.· I am trying to run a native assembler cog via cognew_native.· I can make it work as long as I don't try to pass a parameter to the assembler cog.
I am trying to send a PIN number to the assembler cog.· This new cog is to blink the passed pin.
The following code·sometimes blinks·the pin a few times then stops or just lights up multiple pins.· I think my problem is related to the data variables in my Assembler code.· Any ideas?
#include <stdio.h>
#include <propeller.h>
extern void ScanPin(void*);
void main(void) {
·· pin = 23;
·· cognew_native(ScanPin, (void *)&pin);
while (1) {}
}
Assembler Code:
··········· .area cog(abs)
_ScanPin::
··········· mov····· ParPtr,par·········· //get PAR address
··········· rdlong·· Tmp,ParPtr·········· //get pin#
··········· mov····· Pin,#1·············· //Put 1 into PIN
··········· shl····· Pin,#Tmp··········· ·//Shift PIN left
··
·· ········ mov····· dira,Pin············ //Set dira
Loop1:····· xor····· outa,Pin··········· ·//flip PIN
············mov····· Tmp,cnt············· //delay
············add····· Tmp,Delay
············waitcnt· Tmp,Delay
············jmp ···· Loop1················//flip again
ParPtr:·····res·1
Pin:········res·1
Tmp:········res·1
Delay:······.long·5000000
I am trying to send a PIN number to the assembler cog.· This new cog is to blink the passed pin.
The following code·sometimes blinks·the pin a few times then stops or just lights up multiple pins.· I think my problem is related to the data variables in my Assembler code.· Any ideas?
#include <stdio.h>
#include <propeller.h>
extern void ScanPin(void*);
void main(void) {
·· pin = 23;
·· cognew_native(ScanPin, (void *)&pin);
while (1) {}
}
Assembler Code:
··········· .area cog(abs)
_ScanPin::
··········· mov····· ParPtr,par·········· //get PAR address
··········· rdlong·· Tmp,ParPtr·········· //get pin#
··········· mov····· Pin,#1·············· //Put 1 into PIN
··········· shl····· Pin,#Tmp··········· ·//Shift PIN left
··
·· ········ mov····· dira,Pin············ //Set dira
Loop1:····· xor····· outa,Pin··········· ·//flip PIN
············mov····· Tmp,cnt············· //delay
············add····· Tmp,Delay
············waitcnt· Tmp,Delay
············jmp ···· Loop1················//flip again
ParPtr:·····res·1
Pin:········res·1
Tmp:········res·1
Delay:······.long·5000000
Comments
I am sure that my variables in the Assembler module are not defined properly.· It runs very strange.· As an example, if I add the line· "Testing:· res· 10"· in front of my other reservations, the program fails very differently.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
i.e. use:
I moved the Delay to then begining.· The code runs a bit better but still stops after a few seconds.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ward M. Elder
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ward M. Elder
Lets see:
mov src,dst
or
mov dst,src ?
Or my favorite, under MSP430, it's
call #name
just like the jump above....
jmp #Loop1
Stumbled over the same problem these days ;o)
Or isn't it like in Propeller-Tools PASM?