STM32 DMA2D 目标地址偏移

问题: DMA2D搬运的目标地址如果不是按4字节对齐的, 搬运过后的结果是怎么样的?STM32的数字电路是否可以自己计算出来?

 

2. 源码

void dma2d_address_offset_test(test_t test_mode, uint32_t test_size_by_word){
    uint8_t color_mode_index = 1;
    uint32_t pixel_per_lines = 10;
    uint32_t number_of_lines = test_size_by_word/pixel_per_lines;
    
    uint32_t data = 0x12345678;
    uint8_t i  = 0;
    uint8_t * p = (uint8_t*)address;
    
    address = malloc(test_size_by_word * 4);
    
    if (NULL != address){
        for(i = 1; i <= 8; i++){
            memset((uint8_t*)address, 0, test_size_by_word * 4);
            dma2d_r2m_config((uint32_t *)(address + i), 0, data, color_mode_index, pixel_per_lines, number_of_lines);
            dma2d_transfer_and_wait_complete();
            p = (uint8_t*)(address + i - 1);        
            if ((0 == *(p = (uint8_t*)(address + i - 1))) && (0 != *(p = (uint8_t*)(address + i)))){
                printf("dma2d address offset test ok !, offset: %d byte.\n", i);
            }
            else{
                printf("dma2d address offset test fail !, offset: %d byte.\n", i);
            }
        }
    }
    else{
        printf("malloc is fail !\n");
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

狻猊209

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值