LCDout and large filesize 18F452 -> paging problem?


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Jan 2008
    Location
    Finland
    Posts
    11


    Did you find this post helpful? Yes | No

    Default Looong IF-THEN-ELSE structures?

    > Ok, how about this code, and ONLY this code:

    Well, I dunno.. BUT I got another question..

    What would happen if IF-THEN-ELSE overlaps from memory-page to another? Is it allowed? Is pbp-compiler capable of handle veeeeery loooooong IF-THEN-ELSE structures (like 200lines long?) including gosubs from page to page? If not-should I get a warning? o:-)

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mara View Post
    > Ok, how about this code, and ONLY this code:
    Well, I dunno.. BUT I got another question..
    What would happen if IF-THEN-ELSE overlaps from memory-page to another? Is it allowed? Is pbp-compiler capable of handle veeeeery loooooong IF-THEN-ELSE structures (like 200lines long?) including gosubs from page to page? If not-should I get a warning? o:-)
    I don't have any problem with what you're talking about, with 2.50a anyways. But quite frankly, I just avoid it altogether by just making the 'middle' of the If/Then another routine.
    I've had some programs (one in particular), over 4300 lines long (and that's compacted with a lot of colons like I do often, uncompacted, figure roughly 13,000+ lines). Never had a problem with the amount of code inside of an If/Then, Select Case, While/Wend, or otherwise.

    You tend to forget things like RETURN after a GOSUB, or maybe you RETURN from somewhere that you had GOTO'd instead of GOSUB'd. Keep that in mind. I just fixed a buried GOSUB (one of the drawbacks of 'compacting' source code) that would only show up after the loop went thru itself 32 times and ended up causing a stack overflow which killed my entire OS on the one project. I've been fighting it for over 6 months now.

    And paging really isn't so much of an issue, moreso with 18F series PICs, and even moreso with PBP for the last few years.

  3. #3
    Join Date
    Jan 2008
    Location
    Finland
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    > You tend to forget things like RETURN after a GOSUB..

    Yep, gosubs and if-then-else-endif structures are like women-
    one has to be veeery careful with them.. o:-)

    I downsized the code a little bit - any comments?

    It works if naytto is low,
    If naytto is high then portD.7 wont go high (except pulsout-command)
    Last edited by mara; - 24th January 2008 at 21:14. Reason: pdf updated

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mara View Post
    > You tend to forget things like RETURN after a GOSUB..
    Yep, gosubs and if-then-else-endif structures are like women-
    one has to be veeery careful with them.. o:-)
    I downsized the code a little bit - any comments?
    It works if naytto is low,
    If naytto is high then portD.7 wont go high (except pulsout-command)
    Yes, does the code in Post #6 work?

  5. #5
    Join Date
    Jan 2008
    Location
    Finland
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    > Yes, does the code in Post #6 work?
    Well, did ya mean reversing direction-bit of portD.7?
    I don't think it would resolve the problem-
    in this case the problem is deepper-I think it is in compiler...
    The code works ok, only the LCDout routine is causing problems..
    (=jamming portD.7)

    m.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mara View Post
    > Yes, does the code in Post #6 work?
    Well, did ya mean reversing direction-bit of portD.7?
    I don't think it would resolve the problem-
    in this case the problem is deepper-I think it is in compiler...
    The code works ok, only the LCDout routine is causing problems..
    (=jamming portD.7)

    m.
    Ok, typo on my part...
    TRISD = %10000000 should have been
    TRISD = $40

    Did it work or not?

    Looking at your program as a whole, I think the problem is that the LED is actually coming on, but that it flickers too fast for you to see it. With the pulsout, you are seeing a .13 second pulse, if your code says something to the effect of:
    LED1 = 1
    LED1 = 0
    then you probably won't see it come on at all...unless you got really super special eyes.

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Be careful with 18Fs.. when you write to a PORT you should use LATx instead of PORTx. If you write to adjacent bits, you should write to a shadow register first, then copy it to the whole port to avoid the Read-Modify-Write behaviour.

    I would tend to change the LCDOUT statement... reading the Magn bit (from PORTD.7), save the result to a Temp variable then after show the result. When writing to Magn, you use LATD.7.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts