Shop OBEX P1 Docs P2 Docs Learn Events
Larson scanner looks strange when flashed to Eval board B — Parallax Forums

Larson scanner looks strange when flashed to Eval board B

RaymanRayman Posts: 13,797
edited 2019-12-05 16:10 in Propeller 2
Attached is Jon's Larson scanner code.
It works as expected when loaded to RAM.

But, when burned to flash, it acts strangely...
P58 and P59 stay off and P60 stays on.

Does the bootloader not release control of the flash pins after booting?

Comments

  • I've noticed some weirdness with the pins after booting from flash as well. I tried a number of things to try to get the pins back but haven't had any success.
  • evanhevanh Posts: 15,126
    That would be correct. The smartpins used by the flash loader are not reset. Easy to add.

    Now you mention it, I realise now it never affected me because my regular reusable testing code tests every smartpin for presence as it's first job ... and part of that is to reset each smartpin as it goes.
  • evanhevanh Posts: 15,126
    Slap this in ahead of the COGINIT
    		wrpin	#0, #spi_clk
    		wrpin	#0, #spi_di
    		wrpin	#0, #spi_do
    
  • RaymanRayman Posts: 13,797
    If you were to boot from SD, are different pins affected?
  • RaymanRayman Posts: 13,797
    Maybe something like this would work:
    wrpin   #0,#58+5<<6
    

    To clear everything all a once...
  • evanhevanh Posts: 15,126
    CS and CLK are swapped.
  • evanhevanh Posts: 15,126
    Rayman wrote: »
    wrpin   #0,#58+5<<6
    
    revA can't do that.
  • RaymanRayman Posts: 13,797
    edited 2019-12-05 17:13
    Ok, the one liner seems to work on Rev.B.

    Strangely, it seemed to reboot after flashing with that line included...
    I'm not sure how that is possible...

    I don't know, now it always seems to reboot after 4 seconds...
    Wasn't earlier...
  • evanhevanh Posts: 15,126
    Rayman wrote: »
    Strangely, it seemed to reboot after flashing with that line included...
    I'm not sure how that is possible...
    Huh, it probably depends on the pin levels as the pin sensing starts at early ROM booting. I'm surprised it hadn't been noticed before.

  • RaymanRayman Posts: 13,797
    edited 2019-12-05 17:24
    Just to be clear...
    I think it's the flash loader in the ROM that is not releasing the pins.
    The flash loader using for loading a binary into the flash doesn't matter (?)

    I not even sure... Does a soft reboot reset the smart pins?
  • evanhevanh Posts: 15,126
    edited 2019-12-05 17:33
    Good point I was thinking COGINIT after the second stage flash loader. The post-programming whole chip reset with HUBSET will reset all smartpins.
  • evanhevanh Posts: 15,126
    Where in the source did you add that line?

  • RaymanRayman Posts: 13,797
    First line
  • evanhevanh Posts: 15,126
    Oh, in your own program! Interesting.
  • evanhevanh Posts: 15,126
    To finish answering: COGINIT's zero the associated OUT and DIR registers but don't touch any pin configs.
  • RaymanRayman Posts: 13,797
    So hubset can do a reset:
    %0001_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx     Hard reset, reboots chip
    

    Note: I think this is technically a warm reset as done by code and not by cycling power or reset switch.

    Does this clear the smartpin states?
  • RaymanRayman Posts: 13,797
    evanh wrote: »
    Oh, in your own program! Interesting.

    I think it has to be in the Larson scanner code in order to work...
  • evanhevanh Posts: 15,126
    Google doc:
    Rebooting the Chip

    HUBSET can be used to reset and reboot the chip:

    HUBSET ##$1000_0000 'generate an internal reset pulse to reboot

    I read that as being good as the external hard reset.

  • evanhevanh Posts: 15,126
    Rayman wrote: »
    I think it has to be in the Larson scanner code in order to work...
    If added just in front of the COGINIT at the end of the second stage loading then it would be the same effect but obviously universally applied to all attached programs then.

  • evanhevanh Posts: 15,126
    Rayman wrote: »
    Does this clear the smartpin states?
    Yes it will. Chip has mentioned before that only hubRAM is not cleared on reset. All registers are cleared.
  • RaymanRayman Posts: 13,797
    I just read Wikipedia on warm and hard reset and I'd say it's a warm reset based on that, even if the result is the same...

    Adding to loader might help when programming RAM over serial port, but not when booting from flash.
  • evanhevanh Posts: 15,126
    edited 2019-12-05 18:56
    The HUBSET is physically pulling the hardware reset on the inside of the chip. That's as hard as it can get.

    A soft reset is just a simulated equivalent that goes through the rebooting steps without the hardware actually being reset at all. Wikipedia is heavily PC industry biased but here's a quote anyway "A soft reset is performed by restarting system software without resetting the hardware." - Reset_(computing)

    EDIT: Grr, the forum software doesn't auto handle brackets as part of a link.
  • RaymanRayman Posts: 13,797
    The thing of it is that this reset is internally controlled by code... It's not an external thing like power or reset button...
  • evanhevanh Posts: 15,126
    edited 2019-12-05 18:53
    Rayman wrote: »
    Adding to loader might help when programming RAM over serial port, but not when booting from flash.

    That FlashLoader.spin2 actually inserts a second stage loader (part of itself) into the flash chip. It occupies the first 1 kByte of EEPROM space and so is all that gets loaded by the ROM. It then sets up the smartpins for a fast load of whatever program has be put in there. After that is completed it then COGINITs into the target program. But the smartpins used for the fast loading aren't being turned off at the moment, that's the part I'm adding the three WRPIN #0 instructions to do.

    In terms of the sequence, there is only one instruction, the COGINIT, inbetween my recommended fix and what you've added.

  • RaymanRayman Posts: 13,797
    edited 2019-12-05 18:55
    Ok, I see what you are doing now... So, you can disable the smartpins in the code that is put on the flash chip...
    Interesting...

    That sounds like the best thing... If serial, SD, and flash can all do this...
  • evanhevanh Posts: 15,126
    Rayman wrote: »
    The thing of it is that this reset is internally controlled by code... It's not an external thing like power or reset button...
    That doesn't matter at all.

  • evanhevanh Posts: 15,126
    Rayman wrote: »
    That sounds like the best thing... If serial, SD, and flash can all do this...
    Yes.
Sign In or Register to comment.