Shop OBEX P1 Docs P2 Docs Learn Events
Starting a cog and messing up t.v. — Parallax Forums

Starting a cog and messing up t.v.

mosquito56mosquito56 Posts: 387
edited 2008-02-25 01:05 in Propeller 1
I am trying to start a seperate cog from my main program. Everytime I put cognew my video completely goes haywire. It doesn't make a difference which object is trying to start.

I have tried to put it
··· before the tv start
··· after the tv start
··· inbetween tv start and color setup

I had the same problem with the new graphics.spin.· I am using just using a simple tv driver now.
This only happens when I use the t.v. I always test my programs with propterminal first and never have any problems.

Any ideas?


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·······

······· "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet
········

Comments

  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-22 23:47
    If you are going to ask questions like this, Please, Please, Please post code. If you dont it is almost impossible for anyone to help.
  • mosquito56mosquito56 Posts: 387
    edited 2008-02-23 00:02
    Everyone keeps asking for code. This is a general problem not a specific problem. I was asking if anyone had encountered the problem before not a specific answer to a question. My code is about 400 lines long and·private. How much should I·give up?



    t.v. works fine period.

    I add cognew anywhere and t.v. outputs nothing.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
    ········
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-23 00:08
    As a general remark - not to Mosqwuito who most likely does not get this at all in the first place.

    You can assume that there are very, very few peculiar things in the Propeller. In 99.99% of all cases it is a tiny misunderstanding or even a typo somewhere in your code that is responsible for any odd behaviour. There are examples in the recent past (one solved, one still unsolved due to missing COMPLETE code of the program) that proves this.

    So helping with such issues needs an at least working sub-example of the effect - always.
  • VIRANDVIRAND Posts: 656
    edited 2008-02-23 04:45
    Maybe loose crystal ; are you severely losing horizontal and vertical syncs and color?
    Maybe loose video output connection ; are you getting all kinds of almost static?
    Maybe wrong mode or frequency ; are you using broadcast mode or baseband mode?
    Maybe attach a picture of the screen malfunctioning.
  • Harrison.Harrison. Posts: 484
    edited 2008-02-23 05:07
    My best guess is your cognew is either outputting high on the tv output pins, or you are overwriting memory somewhere. I tend to be careful I don't do this by allocating extremely large spin stack sizes then reducing them after I am done with that cog's code. I find the stack length monitor object that comes with the Propeller Tool to be very useful for final stack sizing.

    Also remember that the first spin cog uses the ram starting from the first unused ram location as stack space. So you'll have to save some free space towards the end of your program in order for it to work. A few of the tv drivers use ram at the end of the memory range for buffer space. You'll surely see weird stuff happening if your code starts messing around with this buffer.

    So post your compiled code size and any source code (third party objects, etc) that you can release. Maybe someone will be able to figure out your problem, even without you posting your private code.

    Harrison
  • mosquito56mosquito56 Posts: 387
    edited 2008-02-23 05:21
    Virand, thanx for the ideas. The problem

    cognew(obj.start,@stack) screen does nothing no change or flickering·whatsoever. Comment line and everything is good.

    Harrison, thanx· a million, that sounds like a good possiblility. Can you recommend a good starting size. The tutorials always used stack[noparse][[/noparse]20] so that's what I use. I will switch it to 200? and go from there.
    How do you avoid the conflict with the t.v. in lower memory? Heres the code
    timerb:"timerb"
    

    PUB main|i,j
      cognew(timerb.start,@stack)
      ' cognew(dummy.start,@info6)
      waitcnt(clkfreq/10+cnt)
    
      'start TV
      start(12)
      'set up colors
      colors[noparse][[/noparse]0]:= $05_59_05_59       'NOTE:  last color here (LSB) is the overall background
      colors[noparse][[/noparse]1]:= $05_05_5B_5B
      colors[noparse][[/noparse]2]:= $BB_06_BB_06     '1: red on white
      colors[noparse][[/noparse]3]:= $BB_BB_bb_bb      'RED
      colors[noparse][[/noparse]4]:= $02_06_02_06     '2: black on white
      colors[noparse][[/noparse]5]:= $02_02_06_06
      colors[noparse][[/noparse]6]:= $8E_5B_8E_5B     '3: Yellow on Green
      colors[noparse][[/noparse]7]:= $8E_8E_5B_5B
      colors[noparse][[/noparse]8]:= $02_04_02_04     '4: black on grey
      colors[noparse][[/noparse]9]:= $02_02_04_04
        'blank card edge color
      colors[noparse][[/noparse]11]:= $06_02_BB_5B     'NOTE:  color 1 on right side (LSB), color 4 on left side (MSB)    
        'card edge color
      colors[noparse][[/noparse]12]:= $5B_02_02_06     
      'red face card colors
      colors[noparse][[/noparse]13]:= $8E_BB_02_06 
      'black face card colors
      colors[noparse][[/noparse]14]:= $8E_02_BB_06
      'button colors
      colors[noparse][[/noparse]15]:=$05_03_04_04 
    'screen1  
    

    All timerb does is turn on a light every second. Still can't turn it off from main.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
    ········
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-23 05:45
    When you start a new cog you must use one of the methods in the current object. This is a known and there will likely be a revision to the compiler to flag it as an error. I think that it will sometimes work and sometimes not. And do make the stack size larger.
  • mosquito56mosquito56 Posts: 387
    edited 2008-02-23 06:03
    Steve,· A very helpful guy named Mike has been helping me with my problems for quite a while and he mentioned the same thing. The t.v. object starts it's own cog in the tv object. Could this be the problem?

    go
    waitcnt(clkfreq/1+cnt) 
    getsettings
    'read
    pub go
     cognew(timerb.starttt,@stack1)
    

    Changed stack to stack[noparse][[/noparse]50] and added above code. Screen turns on and has a small checkered pattern. Tried a couple different screens. Same thing but progress.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet


    Post Edited (mosquito56) : 2/23/2008 6:15:05 AM GMT
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-23 06:12
    I doubt it. The tv object has been used by many people and works very well. In your timerb object what do you do to the output pins?
    Try adding
    PUB startTimer
      timerb.start
    


    And changing
    cognew(timerb.start,@stack)
    


    to
    cognew(startTimer,@stack)
    


    Have you tried this yet?
  • mosquito56mosquito56 Posts: 387
    edited 2008-02-23 06:18
    Steve, I have tried 4 different methods with 4 different ways to start them and none work. I even put in a dummy object that only has
    start
    x:=0
    repeat
     x++
    
    

    i also tried another graphics.spin, no luck. I guess I can try building from ground up again and see where the problem comes in by commenting out until problem disappears. It has to be somewhere in my code.

    Thanx for the help and the stacksize, it never occured to me.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
    ········
  • Chuck McManisChuck McManis Posts: 65
    edited 2008-02-23 07:37
    Hi mosquito,

    Its possible you've run out of COGs but unless you've started a bunch that is unlikely. Something that caught my eye was your message which had this code in it:
      'start TV
      start(12)
      'set up colors
      colors[noparse][[/noparse]0]:= $05_59_05_59       'NOTE:  last color here (LSB) is the overall background
      ...
    
    



    The thing that caught my eye is that I would have expected you to write;
      'start TV
      tv.start(12)
      ...
    
    



    And up in the OBJ section having a statement like

    OBJ
       TV : "TV"
    
    



    So there are really three things that can mess up the TV reliably:
    1. You can change the output of one of the TV's pins to an input (DIRA := 0 for example)
    2. You can overwrite the TV code by loading into the same COG (hard to do from spin directly)
    3. Write to one of the pins the TV code is using.

    --Chuck
  • mosquito56mosquito56 Posts: 387
    edited 2008-02-23 08:32
    only running one cog except for a timer in cog 2, I assume the tv is using one also.

    I am totally confused by the t.v. object, I just grabbed one in the object exchange and copied it. I have no idea how it works so I only use the first 4 colors. I will delete all the non used colors and try that.
    I have been programming for 40 years now and I never mess with video drivers. I get one that works and modify it as best as possible. I never have more than 4 or 5 colors on the screen since I did alot of business programming before coming to the prop. Ask me about databases and we talking my language.

    Thanx, another good idea.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
    ········
  • Chuck McManisChuck McManis Posts: 65
    edited 2008-02-23 11:08
    40 years? Wow! I've got a PDP-5 in my collection which was built in 1968 but I don't have anything from 1967. Probably mostly mainframe suff, IBM 360? The propeller is a bit like the 3350 channel controller come to think of it, but not nearly as power hungry.

    I posted a response in the other thread as well about using a separate object to manage the LED on/off.

    On the TV Object there is a a pretty good demo that comes with it, (if you have the latest Propeller tool download from the Parallax site it is in the Library_Demos folder) I don't know if the one that comes with the prop tool is earlier or later than the one in the Object Exchange here. I used the one with the propeller tool and it worked fine. I've got a second COG that is doing PWM output (see the discussion about high frequency PWM for more details on that)

    --Chuck
  • mosquito56mosquito56 Posts: 387
    edited 2008-02-23 19:05
    ·The first time I programmed a "Computer" was 1968. This was in high school. It used an assembler stye code with a blue puchcard.

    070 'Get number

    071' get second number

    051 'add numbers

    155 print sum in register

    It had a adding maching output, adding machine keyboard.

    You bring up an interesting point.We have digressed back to the 80's. Because we don't have megbytes of ram, the operating systems are very rudementary. It's like having a trs-80 the size of a wallet.

    ·I hate O.T. but since it's my thread what the heck. LOL

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
    ········
  • whickerwhicker Posts: 749
    edited 2008-02-24 23:44
    this whole stack thing is an annoyance.
    if there's anything that would know how much stack it really needs, it would be the compiler.
    spin stack overflow is the kind of thing that makes me nervous about using the Propeller.
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-25 00:36
    @Whicker: Yes and No.
    A compiler can perform a worst case call path analysis to find this out. This is far beyond the general features of the SPIN compiler, but can be done by an external tool also. This can include called external Objects as well as nested formulas, loops, ifs, and cases...

    Recursion has to stop this analysis principally, but this is a rare usage.
    As the call path is generally not a (static) tree, the worst case analysis will be - worst case, which will introduce some overhead, maybe considerable ovrhead...

    The third challenge is that the compiler is principally not aware of the size of the "stack" provided by the COGNEW call.

    In principle I should suppport your request, but just to roughly and conservatively estimate the stack need is not a great deal. Maybe more guideance is called for...

    But I never had a problem when setting it to 20 for shallow call depths...

    Post Edited (deSilva) : 2/25/2008 12:42:10 AM GMT
  • Harrison.Harrison. Posts: 484
    edited 2008-02-25 00:47
    Take a look at 'Stack Length.spin' that's included in the Propeller Tool's library. The documentation contains a bunch of information on what uses stack and why it is non-trivial to calculate at compile time.

    EDIT: deSilva provided a much better explanation then I did... So I removed my slightly extreme example.

    Post Edited (Harrison.) : 2/25/2008 12:54:47 AM GMT
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-25 01:05
    .. but your reference to StackLenght.spin's comments is much more useful smile.gif
Sign In or Register to comment.