Shop OBEX P1 Docs P2 Docs Learn Events
p1 and p2 PASM TUTORIAL — Parallax Forums

p1 and p2 PASM TUTORIAL

pilot0315pilot0315 Posts: 910
edited 2020-02-02 22:07 in Propeller 2
Please start tutorials here and make them simple. REMEMBER THIS TUTORIAL IS FOR THE NOVICE ONLY.
EXAMPLE:
If you are going to use a smart pin please give a totally commented set of code.
Please comment on how paramaters are passed from high level code to p2asm..
In PNUT how to pass anything.

thank you.
martin

Comments

  • evanhevanh Posts: 15,916
    Examples are often snippets. Especially ones for operating the hardware features of the Prop2.

    My testing of the hardware, for example, always has the test routine sitting in the middle of a large wrapper of proven diagnostic code that I keep reusing and adding to. When changing the test, the prior test routine, containing a specific snippet, is replaced with a new test routine for whatever the current topic of conversation on the forum is.

    I did spend a day recently cleaning up one part of a test routine to turn it into a reusable subroutine. I did this partly because its core was duplicating the basic job of first initialisation in the diagnostics wrapper - setting the sysclock, and comport to suit.
  • @evanh,

    yes I am following you there, one of my goals is to automate my test bench to run the tests with different clock settings.

    As usual you are a step ahead of me, but we are aiming in the same direction...

    Mike
  • @Tubular
    Read his stuff many times. Was o.k. so I had to hunt around and with some help from David Carrier was able to get in and out of pasm.
    Now because of the differences in the p2 from p1, I am struggling with the smart pins.
  • Cluso99Cluso99 Posts: 18,069
    pilot0315 wrote: »
    @Tubular
    Read his stuff many times. Was o.k. so I had to hunt around and with some help from David Carrier was able to get in and out of pasm.
    Now because of the differences in the p2 from p1, I am struggling with the smart pins.

    You do realise that you can still use the pins as general purpose I/O without the need for setting up smartpins?
  • evanhevanh Posts: 15,916
    edited 2019-07-16 07:56
    Pilot,
    Here's a quick test I put together for using a couple of smartpins to show two measured PWM levels. Both are configured to monitor the same pin that I'm controlling with a PWM output smartpin.

    It works as is with Fastspin. For Pnut you'll want to copy the init-diag file into the end of the pwm-input file, replacing the #include line.

    PS: The method used here is first option from my earlier post - https://forums.parallax.com/discussion/comment/1473443/#Comment_1473443
    EDIT: Note: This method needs a high-low pulse, it doesn't work for PWM at 100% because there is no edges then. Same for 0%. What happens is the the prior value is retained until there is a complete pulse again.
  • Another good option might be to learn the basics of smartpins using a high level language like Spin, Forth, or Python (whatever you know best) -- that might be easier than trying to master both smartpins and PASM together.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2019-07-16 11:07
    @pilot0315 - I would say this to you and to anyone asking for help. Don't be vague and don't treat help given without acknowledging as promptly as possible. (Imagine you are thirsty and someone gives you a drink, you wouldn't leave it lying around and not acknowledge the kindness either).
    For instance, it always helps us if you show us where you are at. Is it as simple as a shift left or is it really as advanced as smartpin useage? Show your code.
    Then when we reply don't leave us hanging and wondering and taking all these stabs in the dark. Enlighten us, was it helpful or was it too much etc.
  • evanh wrote: »
    Here's a quick test I put together for using a couple of smartpins to show two measured PWM levels. Both are configured to monitor the same pin that I'm controlling with a PWM output smartpin.

    What's a smartpin? I have been curious for awhile. I thought I would've learned by now just by reading discussions but I haven't. The quickest way is to ask.
  • ke4pjwke4pjw Posts: 1,155
    edited 2019-07-16 18:54
    lardom wrote: »
    evanh wrote: »
    Here's a quick test I put together for using a couple of smartpins to show two measured PWM levels. Both are configured to monitor the same pin that I'm controlling with a PWM output smartpin.

    What's a smartpin? I have been curious for awhile. I thought I would've learned by now just by reading discussions but I haven't. The quickest way is to ask.

    "SMART PINS

    Each I/O pin has a ‘smart pin’ circuit which, when enabled, performs some autonomous function on the pin. Smart pins free the cogs from needing to micro-manage many I/O operations by providing high-bandwidth concurrent hardware functions which cogs could not perform as well on their own by manipulating I/O pins via instructions.

    Normally, an I/O pin’s output enable is controlled by its DIR bit and its output state is controlled by its OUT bit, while the IN bit returns the pin's read state. In smart pin modes, the DIR bit is used as an active-low reset signal to the smart pin circuitry, while the output enable state is controlled by a configuration bit. In some modes, the smart pin takes over driving the output state, in which case the OUT bit gets ignored. The IN bit serves as a flag to indicate to the cog(s) that the smart pin has completed some function or an event has occurred, and acknowledgment is perhaps needed."

    From: https://docs.google.com/document/d/1UnelI6fpVPHFISQ9vpLzOVa8oUghxpI6UpkXVsYgBEQ/view#heading=h.nqr04i44rhzx
  • Smart Pins:

    They're like Analog and SPI and PWM pins but more powerful.
    On the P2, every I/O pin is a Smart Pin.
    And no the pin doesn't have to be smart. If you just want a normal digital input pin you can do that.
  • evanhevanh Posts: 15,916
    edited 2019-07-17 13:37
    I'd like to make a distinction between Pin functions and Smartpin functions. The smartpins are a multi-function controller per pin. However, the pins can be configured into different modes of operation, eg: DAC/ADC, and used directly by a cog or streamer, without that pin's associated smartpin being engaged.

    Here's a posting of a block diagram - https://forums.parallax.com/discussion/comment/1473762/#Comment_1473762

    EDIT: I've added DAC paths now ... probably should try indicating DAC and ADC locations, too.
    EDIT2: Oops, I'd messed up the Even/Odd labels. Fixed now. Also showing DAC/ADC placement now.
  • evanh wrote: »
    I'd like to make a distinction between Pin functions and Smartpin functions. The smartpins are a multi-function controller per pin. However, the pins can be configured into different modes of operation, eg: DAC/ADC, and used directly by a cog or streamer, without that pin's associated smartpin being engaged.

    That caught my eye. I didn't follow the development of the P2 but now that it's here I want to start learning about it.
  • evanhevanh Posts: 15,916
    edited 2019-07-17 02:46
    To be fair, the ADC in each pin is intended for use with its smartpin. The ADC produces sigma-delta bitstream, simply placing the bitstream on IN as a series of digital bits. A streamer can keep up with the raw bitstream whereas a cog would alias the signal.

    EDIT: And, of note, the upcoming final Prop2 silicon has improved logic, in both the smartpins and streamers, for resolving this bitstream better than the ES Prop2 does.
  • evanh wrote: »
    EDIT: And, of note, the upcoming final Prop2 silicon has improved logic...
    Thanks.
  • @evanh
    Thanks for the code. It appears straight forward. My understanding level is getting better.
  • @Cluso99
    @"Peter Jakacki"
    @evanh
    @everbody "can we have an @everybody"

    Sorry to not get back to you. Yes I can use the pins as pins. But I have been studying the pins for the counters and other stuff. I am attempting to learn and emulate you code wizards who have been working in the trenches with asm and the math. I am self teaching. The local colleges do not have classes in asm let alone why one for example shifts data right and left to do some magic. So I thank you for your input. It is greatly appreciated.

    You probably saw my post some time ago when in the forum posts regarding the accessories where two persons complained about how much money they spent and were disappointed. Well this is my Sodoku. The best ever learning I have ever experienced and I owe this renewal to Parallax and to all of you who have tried to help me even "he may be be perplexed when I say this" @"Peter Jakacki" with his code.

    I have and continue to read your code. Having scoured the forums I have been able to start to get a handle on this. Sometime I am overwhelmed but after some slow consideration and study make sense of this. I posted a p1 to p2 asm forum. It would be really nice that we could open a forum for the basics of asm code with a structure to have lessons for others to learn this.


    From what I can find on the internet we who attempt or are skilled in asm are a very small community. We need to expand that if possible.

    I find it "facinating" per Captain Spock, single eyebrow raised, of what we can do now as opposed to the IBM 1130 and the HP 2000 my first machines.
    We did not have digital gyros and other sensors.

    Sorry for rambling.

    It is a pleasure to be experimenting with you and the others.
    Thank you for your cooperation. "Mr. Chekov startrek in the latest movies"
    I love scifi that uses good science. We did not get here without the myriad of minds great and small who imagine.

    Martin

    btw fyi

    do you remember this:

    Mr. Mulder why do people like you despite the evicdence to the contrarary believe that the are here?
    What is the response from mulder. "fun" thanks.




  • evanhevanh Posts: 15,916
    edited 2019-08-09 04:21
    Pilot,
    Have you watched the film "Hidden Figures"? It has glamourised enactment of first IBM mainframe going into NASA during early Apollo development. Among other things, I found the film informative of the level of value they got just from having a machine faster than a group of human "computers". It only had one physical job to do ... to get the answers printed on a sheet of paper.

    Because that's all that was wanted of it.

    The capsule and lunar lander computers, on the other hand, were very much wired to lots of sensors and actuators. But of course developing this type of control system had very limited employment opportunities, even now control systems is still relatively small field compared to other computing opportunities.

    Money for developing business transaction processing suites was plentiful. Still is.

  • @evanh
    evanh,

    I have the disk for the movie but have not as of yet seen it. Probably start tonight, since you mentioned it. Last movie was First Man, lunar landing. Slow but was accurate and interesting from my being a flight instructor and mechanic instructor. I grew up watching the NASA programs totally facinated and captivated.

    My family has an unusual NASA connection to the moon program. I normally do not talk about it but, you may find it interesting.
    I grew up in the music industry. My father is a disck jockey and music producer. I am sending a couple of links that you can follow. This is another life long ago for me.

    http://www.magnificentmontague.com/
    https://www.popularmechanics.com/space/moon-mars/a21771/code-for-apollo-moon-landings-on-github/
    https://duckduckgo.com/?t=palemoon&q=burn+baby+burn+lunar+code&ia=web
    https://nmaahc.si.edu/ my father is one of three black diskjockies permenantly exhibited in the smithsonian.

    The reason that I do not talk about this much is to many it would be so fantastic that they would not believe it.

    If you decide to find the book I will get it autographed for you.

    It is a pleasure.

    Martin

    btw when I found out about the apollo code I was amazed.

    I will be sending you another question in the next post hoping that you can send me down a path of understanding.

    And would you like some punch cards I have a case of 1000 of them. LOL!!!!!!!!!!!!!
  • evanhevanh Posts: 15,916
    Ha, I'd always thought that was the name of a song. Sorry, I've never followed music at all really. I have a few tapes and CDs of the likes of Jarre and Oldfield is about all. Avoided ever buying a DVD because of the stupid warnings they place at the beginning.

    Can't say I ever wanted a punch card back in the day either, didn't fit in with the video game culture. I note there is mention of the ROM technology employed in the Apollo modules. Again, it shows the gulf that was between "data processing" and "control systems".
  • @pilot0315 Hi Martin, I am not sure whether I have the most recent version of P2PASM TUTORIAL part 1.pdf What is the date of the most recent version? Have you written any other tutorials?
    Regards,
    Kevin
  • I will look at my files. Look in the P1 forums and I have a longer tutorial for p1. I will get back to you shortly. Again I a still learning this stuff. I do the tutorials so I can have reference material
    and share it with others.

    Martin
  • @kg1

    I am not at my laptop, I will look for some other stuff. I have some code that @evanh helped me with to get started with the p2. I will get it to you.
  • @pilot0315 Thank you Martin. The above tutorial is newer that the one from:
    forums.parallax.com/discussion/169722/simple-question-how-to-do-p1-par-to-get-address-of-first-variable-in-p2pasm-from-spin2
    I will also look in tutorial website.
    Kevin.
  • @kg1

    Kool!
  • @kg1

    @evanh has been helping me understand the P2asm.

    This is a subtraction program. The itod subroutine takes the bcd and makes the ascii characters for printing.

  • @evanh
    @Tubular
    @lardom
    @msrobots
    @ke4pjw
    @ersmith

    Thank you all for your help I am getting much better at this stuff.
  • pilot0315 wrote: »
    @kg1

    This is a subtraction program. The itod subroutine takes the bcd and makes the ascii characters for printing.

    Thank you for sharing @pilot0315
    Kevin.
    682 x 684 - 41K
  • @kg1

    Addition program uses two methods to print.

    Also look at this:
    forums.parallax.com/discussion/170882/reciprocal-counter-demo

    Just tried the code could not get it to work as is but read it. It is fairly clear.
  • @kg1

    Division remainder is not working at this time for odd numbers. Still working on it. Different method to display characters.
Sign In or Register to comment.