Thread: don't know how to solve pointer to union of two different types??

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2020
    Posts
    91

    don't know how to solve pointer to union of two different types??

    I have the following simplified code and I need to have a formula take a uint16_t. This value however comes from multiple sources (ie multiple types) depending on who is calling the formula. The two issues I currently see in the debugger...
    1. pTx assignment how do I do this ?
    2. after I run the program the prtnVals don't look anything like the assignments??

    Can someone please help.

    Code:
    /** * main.c
     */
    #include <msp430.h>
    #include <stdint.h>
    
    
    
    
    #pragma LOCATION (pwmDiv, 0x1800);
    #pragma PERSISTENT(pwmDiv);
    volatile uint16_t pwmDiv = 50;
    
    
    uint16_t itoa(uint16_t k);
    
    
    union rtnVals
    {
        volatile uint16_t Memory;
        float avg;
    };
    
    
    union rtnVals *prtnVals;
    uint16_t test, lowByte = 2;
    uint16_t *pTx = **prtnVals;
    
    
    int main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;   // stop watchdog timer
    
    
        prtnVals->avg = 4454.0;
        prtnVals->Memory = pwmDiv;
    
    
        test = itoa((((*pTx)) >> (4 * lowByte)) & 0x0F);
    }
    
    
    uint16_t itoa(uint16_t k)
    {
        if (k <= 9)
            return '0' + k;
        else
            return 'A' + (k - 10);
    }
    https://cboard.cprogramming.com/imag...AAAElFTkSuQmCC
    Last edited by ridgerunnersjw; 07-07-2022 at 05:44 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointer to union inside struct
    By lv2eof in forum C Programming
    Replies: 4
    Last Post: 05-28-2010, 06:55 PM
  2. Replies: 4
    Last Post: 01-06-2009, 02:08 AM
  3. Replies: 5
    Last Post: 08-05-2008, 10:24 AM
  4. How to convert integral types into pointer types?
    By rohit99 in forum C++ Programming
    Replies: 3
    Last Post: 03-20-2008, 09:57 AM
  5. pointer to pointer how do i solve following problem?
    By kobra_swe in forum C Programming
    Replies: 5
    Last Post: 07-19-2006, 04:49 PM

Tags for this Thread