• AVR Freaks

Hot!Forcing an I/O pin on PIC to specific Value from Memory

Author
newb77777
Junior Member
  • Total Posts : 104
  • Reward points : 0
  • Joined: 2015/04/04 01:46:02
  • Location: 0
  • Status: offline
2019/02/07 19:26:21 (permalink)
0

Forcing an I/O pin on PIC to specific Value from Memory

#define ARM_BIT LATFbits.LATF12 

....

ARM_BIT = 1;

For the above code, I am trying to set the output of the particular I/O pin to 0 BUT through memory access from Windows application program that is written to access memory locations. 
Furthermore, I would like to change the variable while the code is running on the product.
I am able to use the Windows Application program to can access and change variables by finding their address from MAP files and changing their values in data memory with no problems, however I can't find the address to "poke" around to change the value of the ARM_BIT that is really the I/O pin RF12 on PIC32 processor. 
Does anyone have any ideas where I could find the hook to change this variable without changing my code. 
 
I can make changes to the code so this variable is available to me from data memory but I want to see if there is a creative way to do this without that.  
#1

5 Replies Related Threads

    qhb
    Superb Member
    • Total Posts : 9918
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: online
    Re: Forcing an I/O pin on PIC to specific Value from Memory 2019/02/07 19:30:18 (permalink)
    0
    You can't write to a single bit using a pointer, only the whole register (i.e. LATF).
    This is a function of the PIC's architecture.
     
    So, you will need to read LATF, set that bit, and rewrite the whole register.
     
     
    #2
    qhb
    Superb Member
    • Total Posts : 9918
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: online
    Re: Forcing an I/O pin on PIC to specific Value from Memory 2019/02/07 19:36:11 (permalink)
    5 (1)
    If this is just to CLEAR the bit, what you could do is write 0b0001000000000000 to the LATFCLR register.
     
     
    #3
    cobusve
    Super Member
    • Total Posts : 482
    • Reward points : 0
    • Joined: 2012/04/02 16:15:40
    • Location: Chandler
    • Status: offline
    Re: Forcing an I/O pin on PIC to specific Value from Memory 2019/02/08 00:42:55 (permalink)
    5 (1)
    I do not know of any architecture which can access individual bits using pointers. At best architectures would be byte addressible.

    Also take a look at https://www.microforum.cc/ - a great resource for information on PIC and AVR microcontrollers and embedded programming in general. You can also post questions to the experts there.
    #4
    maxruben
    Super Member
    • Total Posts : 3301
    • Reward points : 0
    • Joined: 2011/02/22 03:35:11
    • Location: Sweden
    • Status: offline
    Re: Forcing an I/O pin on PIC to specific Value from Memory 2019/02/08 04:54:55 (permalink)
    0
    cobusve
    I do not know of any architecture which can access individual bits using pointers. At best architectures would be byte addressible.


    Some ARM cortex M3 and M4 based CPUs have a feature called Bit-banding which is, as I understand it, exactly that. It won't help the OP though.
     
    /Ruben
    #5
    Mysil
    Super Member
    • Total Posts : 3321
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: Forcing an I/O pin on PIC to specific Value from Memory 2019/02/08 07:42:10 (permalink)
    0
     
    In PIC32 microcontrollers, I/O pin registers, may be read and written just like memory.
    The memory address of each SFR register is specified in the Datasheet for the device.
     
    Then, in PIC32 devices, most SFR registers, including all I/O pin control registers,
    have hardware gating registers, addressed by the next 3 longword memory addresses,
    to perform bitwise logical operations with existing register content.
        LATFSET = _LATF_LATF12_MASK;  /* Will do:   LATF = LATF |  __MASK; in hardware  */
    Similar there are LATFCLR and LATFINV registers.
    In PIC32MZ device, address of LATF register is 0xBF860530, with LATFSET register at 0xBF860538
     
    Here is example code for PIC32MZ2048EFG100 on a Wi-Fire board:
                                            /* Light a LED, this is LD4 on a Wi-Fire board. */
            uint32_t *pointer;              /* Pointer to memory or SFR register. */
            pointer = 0xBF860638;           /* Address of LATGSET register */
           *pointer = 0x08000;              /* Set a single bit */
            pointer = 0xBF860614;           /* Address of TRISGCLR register */
           *pointer = 0x08000;              /* Clear a single bit */  

     
    Register addresses are also revealed by device support header file, and by Watch window in MPLAB X debugger.
     
        Mysil
    #6
    Jump to:
    © 2019 APG vNext Commercial Version 4.5