Please help me understand this code


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    Hi Bruce and Jersen,

    That is really fast !

    Jerson,
    I was able to observe the proper values by moving the DEBUG line inside the INT handler.

    Is there a more efficient way to observe variables values within a program?
    It seams like LCDOUT and DEBUG are taking too long to operate and are giving false values.

    Thank you

    Mike

  2. #2
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    Bruce,

    I came across this link you wrote Entitled "Using MicroCode Studio ICD
    With The PIC16F628 Microcontroller" http://www.rentron.com/PicBasic/MCS_X3.htm
    Would this enable me to view each step of a program as well as where the PIC timer is at while executing a specific line of code?

    Mike

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Mike,

    Yep. MCS+ ICD is very handy if you have the paid version of MCS+. But if you're trying to view real-time timer values, I would go with MPLAB/MPSIM.

    By the time you LCDOUT, SEROUT, whatever, the timer is long past the value you're displaying.

    What precisely is it you need to do?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    I didn't think I could see real time values with MPSIM using a program written with PBP!
    I will give it a try, I guess I have to invest a little time learning the Stimulus properly, I have done very little assembly and was able to test buttons triggering LEDs but when I started going deeper into this I kind of got distracted with PBP.

    I am building an ultrasonic distance measurement device, I have seen some circuits here and there but I really want to fully understand what I am doing and build my own. I don't have any code to show just yet because I have started to isolate the different parts of my code and it doesn't look like any program right now.
    What I am trying to achieve is using Daryl's Interrupts.
    Using TMR1_INT I send HPWM and using INT_INT I detect the echo from the Rx on RB0.

    I keep trying to tell myself that the PIC is running fast but I am always amazed with how much I underestimate the speed at witch it operates.

    I think I am not too far from something, just wish I could slow down everything and observe what is going on during each operation of code (other than the operation itself)
    I guess MPSIM is probably the way to go?

    Mike

  5. #5
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    I got PBP running with MPSIM and now I finely see what is happening and when, thanks for this info.

    Mike

  6. #6
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    I don't know what's going on here!

    Using MPSIM with watch window
    I have TIMER1 running, I can observe that TMR1H=218 and TMR1L=8

    testa is a word variable.

    I execute this operation:
    testa = TMR1H
    and I see that testa = 218
    Then I do this:
    testa = TMR1H * 256 + TMR1L
    However now testa = 8 instead of 55816

    What am I missing?

    PS: Sorry for mistyping Darrel's name in post #8, I know a Daryl and it just came out without thinking!

    Mike
    Last edited by lilimike; - 3rd May 2010 at 04:37. Reason: PS for Darrel

  7. #7
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    When I send the value of testa on a DEBUG line I get the proper value so it must be a setting in MPSIM somewhere.
    I can't figure out why there would be such a setting though!

    Mike

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