This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

syntax error when assigning pointer to DMA in msp430fg4619

Other Parts Discussed in Thread: MSP430FG4619

Hi,

             I am getting "invalid type conversion " error on compiling the code in both cases. we have used up the 64k code space and the code has exceede beyond , so we are facing this problem.

DMA0DA = (__SFR_FARPTR)&buff1;  //Assigning destination address

DMA0SA = (void (*)())&U1RXBUF;

1. processor used msp430fg4619

2. worbench CCE v3.2

configured the data model as large and made the necessary changes i.e., included the header files, selected msp430x etc.

kindly give a step wise procedure while migrating from the small model to large model.

Regards,

Chinmay

  • Hi,

    I am not sure you can assign values to DMA0DA & DMA0SA directly in this form. You will have to use __data16_write_addr intrinsic functions for this. See if this compiles:

    __data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &buff1);
    __data16_write_addr((unsigned short) &DMA0SA,(unsigned long) &U1RXBUF);

    Regards,

    Praval

  • Hi,

    Just an addition to my above post. When you use the above functions you can use any memory model, small, medium or large. If you are using Large memory model then even void * will work.

      DMA0SA = (void *)(&U1RXBUF);

      DMA0DA = (void *)(&U1RXBUF);

    These statements should work with only large memory model.

    Regards,

    Praval

  • Hi Praval,

                   Thanks for your prompt response.

    1. suggestion 1 --> i think that should work but the function is not defined in the intrinsics.h so , i will have to create a Ext_intrinsics.asm and compile it . i will try that out shortly. it gives a linking error , " unidentifiable function" otherwise .

    2. suggestion 2--> i have already tried it but it still gives linking error, and warning even in large data model( selectable in the runtime model options). I am not sure as to how should I invoke the large memory model ?

    Regards,

    Chinmay

  • Hi,

    I think CCEv4 does have the functions I used. However I think you can do this even without using the functions. Try this out and see if it works.

    unsigned long* dma_src;
    unsigned long* dma_dst;

      dma_src = (unsigned long*)(&DMA0DA);
      dma_dst = (unsigned long*)(&DMA0SA);

      *dma_src = (unsigned long)(&U1RXBUF);
      *dma_dst = (unsigned long)(&U1RXBUF);

    Regards,

    Praval

  • hi,

    none of the above has helped so far, and we do not have a license for unlimited use of CCEV4. I am still trying to compile the asm file with the c code. with intrinsic functions as discussed earlier.

    Regards,

    Chinmay

  • Hi,

    I did not get your above post "still trying to compile the asm file with the c code with intrinsic functions as discussed earlier". Did you try the code below in a C file (NOT using the intrinsic functions at all).

    unsigned long* dma_src;
    unsigned long* dma_dst;

      dma_src = (unsigned long*)(&DMA0DA);
      dma_dst = (unsigned long*)(&DMA0SA);

      *dma_src = (unsigned long)(&U1RXBUF);
      *dma_dst = (unsigned long)(&U1RXBUF);

    What is the compiler error/warning that you get ?

    Regards,

    Praval

  • hi,

             i tried the above, it compiled without error but it did not do the intended function. ie. RXBUF did not get the data during communication. i also doubt it since 

      *dma_dst = (unsigned long)(&U1RXBUF); we would be assigning the value of the address to dma_dst. that would not point the address to the location of RXBUF.( correct me if I am wrong )

    I have reverted back to the small model and am getting the following warning :

    "warning: conversion from pointer to smaller integer
    "../9_serial_comm_fun.c", line 486: warning: integer conversion resulted in truncation
    "../9_serial_comm_fun.c", line 486: warning: a value of type "unsigned short" cannot be assigned to an entity of type "__SFR_FARPTR"

    the code is functional although i am not aware of the implications.  i donot wont to code in assembly for the intrinsic function as it can be very dangerous for code of this size and complexity. if someone thinks otherwise do let me know.

    TI tech support has been of very little help and we have really run out of options.

    Regards,
     

     

  • Hi,

    When you execute this code:

    unsigned long* dma_src;
    unsigned long* dma_dst;

      dma_dst = (unsigned long*)(&DMA0DA);
      dma_src = (unsigned long*)(&DMA0SA);

      *dma_src = (unsigned long)(&U1RXBUF);
      *dma_dst = (unsigned long)(&buff1);

    what happens?

    Ideally when you execute the first two statements, dma_dst will be 0x1D6 (address of DMA0DA) and that of dma_src will be 0x1D2 (address of DMA0SA).

    Next when you do *dma_src = (unsigned long)(&U1RXBUF) the address of U1RXBUF (which is 0x7E) should be written at address pointed to by dma_src. dma_src points to 0x1D2, which is DMA0SA register. Hence the value of DMA0SA should become 0x7E. Similarly the value of DMA0DA should become the address of buff1. For example if the variable buff1 is at address 0x1100 then DMA0DA should become 0x1100. Can you check if your registers are getting the proper values.

    Regards,

    Praval

  • Hi,

    Please note that in my last post I have assigned dma_dst to DMA0DA and dma_src to DMA0SA. Earlier I had assigned them the other way around, with dma_dst pointing to DMA0SA which may have caused confusion. Please check if you have done the assignments correctly in your code.

    Regards,

    Praval

  • hi,

           for some strange reason, the values dont get assigned

    dma_dst = (unsigned long*)(&DMA0DA);
      dma_src = (unsigned long*)(&DMA0SA);

    should put the address of the respective registers in to respective pointers but that does not happen ? i cant figure out why, ? but tell me what is the reasoning behind this, as in by doing this how do we by pass the requirement of intrinsic function call as mentioned in the datasheet?

    Regards,

    Chinmay

  • yes, sure that was not a problem we took care of it .

  • Hi,

    This is what the IAR header file has to say about the intrinsics.

     /*
       * Intrinsic functions to allow access to the full 1 Mbyte memory
       * range in small data model.
       *
       * The functions are available in medium and large data model
       * as well, however it is recommended to access memory using normal

       * __data20 variables and/or pointers.

    */

     /*
       * The following two functions can be used to access 20-bit SFRs in the
       * lower 64kB. They are only available in extended mode (--core=430X).
       */

    I was trying to access the registers using pointers to solve the problem. In IAR the code seems to work properly so that the values are assigned in the DMA registers properly.

    Regards,

    Praval

  • Hi,

    what version of IAR do you use ? we have V3.41, in worst case we may have to migrate to IAR, but it would be very disappointing if CCE fails to address this problem as we have already devleoped and tested more than 70% code so far in CCE, migrating at this point would be an unneeded burden not to mention the cost of procuring the compiler being wasted. I hope the developers take a note of this.

    Regards,

    Chinmay

  • Hi,

    My IAR Version is 4.11B. Sorry, I do not have access to CCE or else I might have been of a little more help. May be somebody from TI can address this problem.

    Regards,

    Praval

  • Hi,

    This may sound a bit silly but can you try this out:

    unsigned long* dma_src;
    unsigned long* dma_dst;

      dma_dst = (unsigned long*)(0x1D6);
      dma_src = (unsigned long*)(0x1D2);

      *dma_src = (unsigned long)(0x7E);
      *dma_dst = (unsigned long)(&buff1);

    What I have done above is directly provide the address for the pointer.Any C Compiler should understand this and dma_dst should start pointing to 0x1D6 and dma_src to 0x1D2 after execution of these statements.

    Regards,

    Praval

  • unsigned long* points to data that is of type unsigned long, it's not the pointer that is of that type, but the data..

    uint8_t* __data20 should implicitly be able to point inside the entire address space of the MSP430X... For some reason

    I cannot get it to work with IARv5.10.4

     

    Regards,

    Mihai Galos

  •  here's what I did to access data anywhere in the memory:

     

    uint8_t __data20 * p_writeToAddress;
    void write_to_MSPFlash(volatile uint8_t uc_data,uint32_t ul_address)
    {

      WDTCTL = WDTPW + WDTHOLD;
      FCTL3 = FWKEY;
      FCTL1 = FWKEY+WRT;
     
      p_writeToAddress = (uint8_t __data20*)ul_address;
      *p_writeToAddress = uc_data;
     
      FCTL1 = FWKEY;
      FCTL3 = FWKEY + LOCK;
     
    }

    int main()

    {

    write_to_MSPFlash(2,0x45bf0);

    return 0;

    }

**Attention** This is a public forum