18F46K22 being dyslexic


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: 18F46K22 being dyslexic

    READ-MODIFY-WRITE (R-M-W).
    Especially at 64Mhz.

    Use LATB instead of PORTB
    DT

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: 18F46K22 being dyslexic

    Never had an issue with using PORT at 64MHz... but i gave it a go...

    Modified code to...

    Code:
    BAT1BLEED VAR LATB.7
    BAT1BLEEDIND VAR LATB.6
    BAT2BLEED VAR LATB.5
    BAT2BLEEDIND VAR LATB.4
    ALARM VAR LATB.3
    And, i get BAT2BLEEDIND and ALARM LED's on during initialisation phase, and then the ALARM LED only comes on when it's running. Which is odd since that section of code for the alarm LED has been commented out.

    The batteries are sufficiently unbalanced to cause it to try to balance them. The LCD readings are,
    0346 0377 0031

    Oh, i forgot to mention I'm running the last release of 2.60 with PBPL

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: 18F46K22 being dyslexic

    ok, i modified the cod to use a temporary byte variable in ram and then write the var to LATB as follows...

    Code:
    TEMPPORTC VAR BYTE
    
    BAT1BLEED VAR TEMPPORTC.7
    BAT1BLEEDIND VAR TEMPPORTC.6
    BAT2BLEED VAR TEMPPORTC.5
    BAT2BLEEDIND VAR TEMPPORTC.4
    ALARM VAR TEMPPORTC.3
    Code:
    IF BAT2TEMP > BAT1TEMP+5 THEN 
        BAT2BLEED = 1
        BAT2BLEEDIND = 1
        BAT1BLEED = 0
        BAT1BLEEDIND = 0    
        BAT2BLEEDCOUNT = 0
        LATB = TEMPPORTC
    ELSE
    for diagnostics i modified the LCD command to the following...

    Code:
    LCDOUT $FE, $80, DEC4 BAT1TEMP, " ", DEC4 BAT2TEMP, " " 
    IF BAT1TEMP > BAT2TEMP THEN
        LCDOUT DEC4 (BAT1TEMP - BAT2TEMP), " "
        ELSE
        LCDOUT DEC4 (BAT2TEMP - BAT1TEMP), " "
    ENDIF
    LCDOUT $FE, $C0, BIN8 TEMPPORTC
    the second line on the LCD reads
    Code:
    00110000
    But, again, only the ALARM LED is on...
    So, the temp var is correct, but it's not setting to port correctly????

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: 18F46K22 being dyslexic

    Apologies for the multiple posts, I'm just documenting what I've done for diagnostics...

    Just for fun i decided to read the LATB register back and display it on the LCD...

    Code:
    LCDOUT $FE, $C0, BIN8 TEMPPORTC, " ", BIN8 LATB
    and the LCD reads...

    Code:
    00110000 00110000
    so... it's setting LATB correctly... but it's not giving me the output????

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: 18F46K22 being dyslexic

    Reading the LATB register does not show the actual state of the pins.
    Reading PORTB does, so you might want to add PORTB to your LCD readout like in the image below.

    I've run your program in Proteus and everything seems fine.
    I did add PORTB to the LCD, it's on the third line.

    Obviously, a simulator doesn't prove that it will work on real hardware, but Proteus is really really good.



    If your LAT register shows 1's, and the TRIS register is 0's then the PORT register should show the same values as the LAT register.
    DT

  6. #6
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: 18F46K22 being dyslexic

    Darrel, I'm getting lamer and lazier every day. I have Proteus, but never got it to work with PBP. Do you have a 'quick-start' guide of some sort to get me started?
    Charles Linquist

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: 18F46K22 being dyslexic

    Quote Originally Posted by Charles Linquis View Post
    Darrel, I'm getting lamer and lazier every day. I have Proteus, but never got it to work with PBP. Do you have a 'quick-start' guide of some sort to get me started?
    Hi Charles,

    I didn't, but I just recorded a simple demo that should get you going.
    Unscripted, umms and sniffles included.

    http://support.melabs.com/DT/Proteus...oteusDemo.html
    Last edited by Darrel Taylor; - 2nd August 2012 at 23:25.
    DT

  8. #8
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: 18F46K22 being dyslexic

    Darrel,










    Thanks! That got me going. Now I just have to learn to use Proteus' schematic capture. I normally use Altium.

    Why didn't LabCenter do this? You should sell your efforts to them. And then you should do more on other topics.
    Debugging/simulation in all its forms seems like fertile ground.
    Charles Linquist

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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