Menu

16f59 portd & porte inoperative

2016-10-13
2016-10-15
  • Don Rosselot

    Don Rosselot - 2016-10-13
    I can't seem to get PORTD and PORTE to operate on a PIC 16f59 chip. Below is a program to toggle all ports off and on. PORTA, PORTB, and PORTC work fine.
    

    ;Chip Settings
    #chip 16F59, 4
    #config CP=OFF, WDT=OFF, OSC=XT
    DIR PORTA b'00000000'
    DIR PORTB b'00000000'
    DIR PORTC b'00000000'
    DIR PORTD b'00000000'
    DIR PORTE b'00000000'

    Begin:
    PORTA = b'11111111'
    PORTB = b'11111111'
    PORTC = b'11111111'
    PORTD = b'11111111'
    PORTE = b'11111111'

    Wait 250 ms

    PORTA = b'00000000'
    PORTB = b'00000000'
    PORTC = b'00000000'
    PORTD = b'00000000'
    PORTE = b'00000000'

    Wait 250 ms
    Goto Begin

    I am using the latest build, 95.009. I wrote a C program with MPLAB and all ports worked fine.

    Any suggestions would be helpful!
    Thanks.

     
  • Anobium

    Anobium - 2016-10-13

    Sorry works here ok. I used your code.

    Porta - 4 LEDS on/off
    Portb - 8 LEDS on/off
    Portc - 8 LEDS on/off
    Portd - 8 LEDS on/off
    Porte - 4 LEDS on/off

     
  • Don Rosselot

    Don Rosselot - 2016-10-13

    I can't imagine why it doesn't work here. I just loaded my C program from MPLAB and all ports work as expected. I deleted my old GCBasic, downloaded a fresh version, compiled the same file I listed here, and ports D and E do not work. I tried both a PICkit 2 and 3, same results.
    I have programmed quite a few different chips and program combinations without any problems (Other than my many coding mistakes) , until this.
    Again, any suggestions are welcome. And thank you for the quick response!

     
  • Anobium

    Anobium - 2016-10-14

    Post your asm as an attachment. Let me have a look.

     
  • Don Rosselot

    Don Rosselot - 2016-10-14

    Here you go. I hope you find something in there.

     
  • Anobium

    Anobium - 2016-10-14

    Thank you..

    Would you be able to post asm from working solution? I think I need it

     
  • Anobium

    Anobium - 2016-10-14

    And, what assember are you using?

     
  • Don Rosselot

    Don Rosselot - 2016-10-14

    I have included the C source and dissassembly file for the working code from MPLAB-X using XC8 compiler. I don't see where MPLAB creates a .asm file, only the dissassembly file. I hope it helps.

     
  • Anobium

    Anobium - 2016-10-14

    Hugh and i have looked into this. Looks like the assembler was incorrectly setting a bit. Puzzled here why it works in the Simulator but not on the real chip. Ho hum. The did confuse me for a few minutes.

    Please download this file core12.dat and place in your chipdata folder. Recompile, test and report back here with your results. :-)

    Thanks

     
  • Don Rosselot

    Don Rosselot - 2016-10-14

    That did it!
    I think I am near the limits of rewrites to the flash memory on this chip trying everything I could think of.
    Thank you and Hugh so much for your help!

     
  • Anobium

    Anobium - 2016-10-14

    We did think..... wow an old chip... why?

    But, thank you letting us know and now everyone can be happy that the 16f59 works!

    :-)

     
  • Don Rosselot

    Don Rosselot - 2016-10-14

    If I am reading the chipdat for the 16f59 correctly, the NoBankRAM should be 0A:1F, not 0A:0F.

    Thanks again, guys.

     
  • Hugh Considine

    Hugh Considine - 2016-10-15

    Glad to help!

    The NoBankRAM section in the chip data file sounds correct - it refers to the area of RAM that can be accessed regardless of which bank is currently selected. The 16F59 does have RAM from 0x0A to 0x1F in bank 0, but only 0x0A to 0x0F can be accessed while another bank is selected. If for example bank 3 is selected, the PIC would be working with addresses between 0x60 and 0x7F. Accessing 0x6A to 0x6F would map back to 0x0A to 0x0F, but accessing 0x70 would access location 0x70 (not 0x10).

     

Log in to post a comment.