Shop OBEX P1 Docs P2 Docs Learn Events
Programming Help.... — Parallax Forums

Programming Help....

Shabbir EzziShabbir Ezzi Posts: 7
edited 2009-11-17 00:06 in Propeller 1
[font=Verdana,]I have the following program, when the program sense that the input 6 is high, it is suppose to show a different menu screen. The problem that i am having is that every time I make input 6 high the program locks up.. can any tell me what I am doing wrong here...[/font]

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-16 20:31
    You're calling the LCD_debug routines from a different cog from the one that was initialized. Each cog has its own set of I/O registers. Your call to lcd.init is done in one cog (the default one) and your other calls are done from a 2nd cog started by the COGNEW. The lcd.init initializes one set of registers and particularly sets some pins to outputs. The 2nd cog doesn't set the pins to outputs, tries to operate the LCD and can't because all of its I/O direction register bits are set to input mode.

    The solution is to use only one cog. You don't need a separate cog anyway for the program you listed. Just change the "cognew(MonitorInputs(4),@stack[noparse][[/noparse]0])" to "MonitorInputs(4)" and see what happens.
  • Shabbir EzziShabbir Ezzi Posts: 7
    edited 2009-11-16 22:46
    I wanted to have dedicated COG to monitor the inputs, so if the user was to press any keys this would be captured at higher priority.. Since I will also be using another cog to handle the AD conversions.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-17 00:06
    The cog that does the LCD I/O has to effectively "own" the LCD. It's possible to share a resource like an LCD between two cogs, but you have to be careful for how it's done and I don't suggest it for beginners to multi-processing.

    I suggest you go back to the design stage and discuss all of what you want to accomplish and start with how to divide up various functional tasks among different cogs.· You will waste a lot of time and energy trying to make your existing program work, particularly when you try to add additional functionality.
    ·
Sign In or Register to comment.