BME operation

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

BME operation

Jump to solution
1,174 Views
danielecortella
Contributor V

Hi all,

i have to do this operation for write a pixel value on a LCD, i'm tring to do this faster.

I want to change this command:

     tmp_pixel = (buff[pointer] << 8) | buff[pointer+1];//elaboro i dati letti convertendoli in 16bit

with:

  BME_BITFIELD_INSERT(&tmp_pixel, 8, 7) = buff[pointer];

  BME_BITFIELD_INSERT(&tmp_pixel, 0, 7) = buff[pointer+1];

but every time i have an error PE_ISR(Cpu_Interrupt)

the macro is this:

  /******************************************************************************

    * macro used to generate hardcoded bit field insert address (BFI).

    *

    *******************************************************************************/

   /*****************************************************************************//*!

         *

         * @brief  generates BME bitfield insert operation addresss (hardcoded 32-bit address).

         *       

         * @param[in]   ADDR  32-bit address.

         * @param[in]   bit      bit number, 0-based.

         * @param[in]   width  bitfield width, 1-based.

         * 

         * @return  hardcoded 32-bit address.

         *

         * @ Pass/ Fail criteria: none.

         *

      *****************************************************************************/   

    #define BME_BITFIELD_INSERT(ADDR,bit,width)        (*(volatile uint32_t *)(((uint32_t)ADDR)   \

                                  | (BME_OPCODE_BITFIELD <<26)  \

                                  | ((bit)<<23) | ((width-1))<<19))   

Thanks

1 Solution
875 Views
yasuhikokoumoto
Senior Contributor I

Hi Daniele Cortellazzi,

thank you for the code. I have to apologize to you. I made you confused.
Regarding BME_BITFIELD_INSERT, the case that subtract 0xF0000 is only for GPIO. For the other peripherals of which start address is 0x40000000 case, your original macro was valid.
By the way, now I must say sad information. I checked again the Reference Manuals and have found almost all KL devices don't support BFI operation for SRAM_U. They support it only for the peripherals (i.e. address is from 0x40000000). If you want to use BFI for SRAM_U, you should adopt KL03.

Best regards,
Yasuhiko Koumoto.

View solution in original post

0 Kudos
12 Replies
875 Views
danielecortella
Contributor V

Hi,

no this didn't solve the problem ....

0 Kudos
875 Views
yasuhikokoumoto
Senior Contributor I

Hi Daniele Cortellazzi,


is the tmp_pixel located in the GPIO address area? If it is so, the BME macro would be useless. It is why the bit 19 of the GPIO address will collide into the BME setting. You should use the BME alias area of GPIO. That is, from 0x400FF000 to 0x400FFFFF should be converted to from 0x4000F000 to 0x4000FFFF.  Probably you might change the macro as the following.

    #define BME_BITFIELD_INSERT(ADDR,bit,width)        (*(volatile uint32_t *)(((uint32_t)ADDR-0xF0000)   \
                                  | (BME_OPCODE_BITFIELD <<26)  \
                                  | ((bit)<<23) | ((width-1))<<19))   

Does this help you?

Best regards,
Yasuhiko Koumoto.

0 Kudos
875 Views
danielecortella
Contributor V

Thanks for the support.

No this didn't solve the problem. I will no use the BME for the moment, i haven't time to undestand the problem now. Thanks

0 Kudos
875 Views
yasuhikokoumoto
Senior Contributor I

Hi Daniele Cortellazzi ,

can you let me know the tmp_pixel address for my future learning?

Best regards,

Yasuhiko Koumoto.

0 Kudos
875 Views
danielecortella
Contributor V

Sure,

tmp_pixel is define as unsigned short tmp_pixel = 0; and in my code his address is 0x2003270

Best regards

   

0 Kudos
875 Views
yasuhikokoumoto
Senior Contributor I

Hi,

thank you but it is 0x20003270, isn't it?

Best regards,

Yasuhiko Koumoto.

0 Kudos
875 Views
danielecortella
Contributor V

Yes, my error. Is 0x20003270.

0 Kudos
875 Views
yasuhikokoumoto
Senior Contributor I

I'm sorry. May I ask one more question. Is BME_OPCODE_BITFIELD 4? If it is so, I have no further comments.

Best regards,
Yasuhiko Koumoto.

0 Kudos
875 Views
danielecortella
Contributor V

No problem, the file that i use is this.

876 Views
yasuhikokoumoto
Senior Contributor I

Hi Daniele Cortellazzi,

thank you for the code. I have to apologize to you. I made you confused.
Regarding BME_BITFIELD_INSERT, the case that subtract 0xF0000 is only for GPIO. For the other peripherals of which start address is 0x40000000 case, your original macro was valid.
By the way, now I must say sad information. I checked again the Reference Manuals and have found almost all KL devices don't support BFI operation for SRAM_U. They support it only for the peripherals (i.e. address is from 0x40000000). If you want to use BFI for SRAM_U, you should adopt KL03.

Best regards,
Yasuhiko Koumoto.

0 Kudos
875 Views
danielecortella
Contributor V

Thanks for the information.

0 Kudos
875 Views
yasuhikokoumoto
Senior Contributor I

Hi Daniele,

although I don't know why the error happens, at least you should shift assigning value by the bit position.

[before]

BME_BITFIELD_INSERT(&tmp_pixel, 8, 7) = buff[pointer];

BME_BITFIELD_INSERT(&tmp_pixel, 0, 7) = buff[pointer+1];

[after]

BME_BITFIELD_INSERT(&tmp_pixel, 8, 7) = buff[pointer]<<8;

BME_BITFIELD_INSERT(&tmp_pixel, 0, 7) = buff[pointer+1]<<0;

I think BME would not help speed up because it initiates read-modify-write for the tmp_pixel internally.

tmp_pixel = (buff[pointer] << 8) | buff[pointer+1];

would result in one write for the tmp_pixel.

I think you are using a Cortex-M0+ device because you use BME. If it is correct, you'd better use FGPIO (Fast GPIO) which is mapped on the alias area of the normal GPIO  if the tmp_pixel is located on the GPIO area.

Best regards,

Yasuhiko Koumoto.

0 Kudos