您尚未登录。

楼主 # 2022-06-27 13:50:12

wm20031015
会员
注册时间: 2017-10-18
已发帖子: 66
积分: 170

上海航芯ACM32F403RET7开发板试用

晕哥的淘宝设点买了个板,得空试了下开发板点灯测试正常,测试用trace32连接的时候提示内核问题,cortex m33还是star core?
qqq.png

选择cortex m33跑个点灯倒是没报错。
qqq1.png

写下载算法的时候遇到问题了,复位芯片后再下载,擦除时间算是正常的,程序运行的时候,不复位芯片下载,这个擦除时间很长,是重新配置时钟不成功?然后按64M配置的延迟导致出问题了?有大佬指点下,会不会芯片初始化有遗漏哪个寄存器没设置?

头文件如下:

#ifndef	__ACM32F4__H
#define __ACM32F4__H

#define CHIP_FLASH_SIZE     0x7ffff
#define FLASH_PAGE_SIZE     0x200

#define SCU_RCR             *(unsigned int *)(0x40010800UL + 0x00)  
#define SCU_CCR1            *(unsigned int *)(0x40010800UL + 0x10) 
#define SCU_RCHCR           *(unsigned int *)(0x40010800UL + 0x24) 

#define SCU_RCR_REMAP_IMP   (1 << 16)
#define SCU_RCHCR_RCHRDY    (1 << 9)
#define SCU_RCHCR_RCH_EN    (1 << 0)

#define EFC_CTRL            *(unsigned int *)(0x00100000UL + 0x00)
#define EFC_SEC             *(unsigned int *)(0x00100000UL + 0x04)
#define EFC_TERASE          *(unsigned int *)(0x00100000UL + 0x0c)
#define EFC_TPROG           *(unsigned int *)(0x00100000UL + 0x10)
#define EFC_STATUS          *(unsigned int *)(0x00100000UL + 0x14)   
#define EFC_INTSTATUS       *(unsigned int *)(0x00100000UL + 0x18)   
#define EFC_INTEN           *(unsigned int *)(0x00100000UL + 0x2C)    
#define FMC_FLSTS_OVF_Msk   0x01
#define SCB_VTOR           *(unsigned int *)(0xE000E000UL + 0x0D00UL + 0x08)

#define EFC_CTRL_PAGE_ERASE_MODE        (1 << 1)
#define EFC_CTRL_PROGRAM_MODE           (1 << 0)

#define EFC_STATUS_NVR4_LOCK            (1 << 4)
#define EFC_STATUS_NVR3_LOCK            (1 << 3)
#define EFC_STATUS_NVR2_LOCK            (1 << 2)
#define EFC_STATUS_NVR1_LOCK            (1 << 1)
#define EFC_STATUS_EFLASH_RDY           (1 << 0)

//计算编程等待时间,默认时钟为64M
#define SYS_CLK             (64)
#define FLASH_PROG_DELAY    (12 * SYS_CLK)
#define FLASH_ERSAE_DELAY   (6 * 1000 * SYS_CLK)

//系统时钟配置
#define system_init()   do{                 \
    SCU_RCR |= SCU_RCR_REMAP_IMP;           \
    EFC_TPROG = FLASH_PROG_DELAY;           \
    EFC_TERASE = FLASH_ERSAE_DELAY;         \
    if(0 == (SCU_RCHCR & SCU_RCHCR_RCH_EN)) \
    {                                       \
        SCU_RCHCR |=  SCU_RCHCR_RCH_EN;     \
        while(0 == (SCU_RCHCR & SCU_RCHCR_RCHRDY)); \
    }                                       \
    SCU_CCR1 = 0;                           \
    EFC_CTRL = 0x2400;                      \
}while(0)

#define flash_readywait(value)  do{     \
    unsigned int i;                     \
    i = value;                          \
    do{                                 \
        i --;                           \
        if((EFC_STATUS & EFC_STATUS_EFLASH_RDY) != 0) break; \
    }while(i);                          \
}while(0)

#define flash_program()    do{                  \
    unsigned int ii;                             \
    EFC_CTRL |= EFC_CTRL_PROGRAM_MODE;          \
    for(ii=0; ii<FlashParameter.size; ii += 4)     \
    {                                           \
        EFC_SEC = 0x55AAAA55;                   \
        *(unsigned int *)(FlashParameter.addr + ii) = *((unsigned int *)(&FlashParameter.data[ii])); \
        flash_readywait(FLASH_PROG_DELAY);      \
    }                                           \
    EFC_CTRL &= ~EFC_CTRL_PROGRAM_MODE;         \
    FlashParameter.status = 0;                  \
}while(0)

#define flash_erasepage()   do{                 \
    EFC_CTRL |= EFC_CTRL_PAGE_ERASE_MODE;       \
    EFC_SEC = 0x55AAAA55;                       \
    *(unsigned int *) FlashParameter.addr = 0x00; \
    flash_readywait(FLASH_ERSAE_DELAY);         \
    EFC_CTRL &= ~EFC_CTRL_PAGE_ERASE_MODE;      \
    FlashParameter.status = 0;                  \
}while(0)

#define flash_erasechip()   do{                 \
    unsigned int i;                             \
    EFC_CTRL |= EFC_CTRL_PAGE_ERASE_MODE;       \
    for(i=0; i<FlashParameter.size; i += FLASH_PAGE_SIZE)   \
    {                                           \
        EFC_SEC = 0x55AAAA55;                   \
        *(unsigned int *)(i) = 0x00;            \
        flash_readywait(FLASH_ERSAE_DELAY);     \
    }                                           \
    EFC_CTRL &= ~EFC_CTRL_PAGE_ERASE_MODE;      \
    FlashParameter.status = 0;                  \
}while(0)

#endif

main函数如下:

//***********************************************************************************************************
//  Ver 1.0
//      2022.04.02  1、新建文件。
//***********************************************************************************************************
//#include    "gd32l23x_config.h"
//#include    "bat32g135_config.h"
#include    "acm32f4_config.h"

//参数块定义
typedef struct{
    unsigned int  flashaddr;  //0x800,芯片起始地址
    unsigned int  flashwidth; //0x804,1=8bit,2=16bit,4=32bit
    unsigned int  width;      //0x808,数据总线位宽
    unsigned int  offset;     //0x80c,
    unsigned int  addr;       //0x810,FLASH操作地址
    unsigned int  size;       //0x814,擦除、写入字节数
    unsigned int  reserved;   //0x818,
    unsigned int  status;     //0x81c,in: 1=program, 2=erase, 5=chip erase, out: 0=o.k., 0x100=fail
    unsigned char   data[4096]; //0x820,缓冲区起始地址
}FlashParameter_Str;

static FlashParameter_Str FlashParameter __attribute__((at(0x20000800)));
//static FlashParameter_Str FlashParameter __attribute__((section(".ARM.__at_0x20000800")));

enum{
    FLASH_PROGRAM       = 0x01,
    FLASH_ERASE_PAGE    = 0x02,
    FLASH_CHIP_ERASE    = 0x05,
};

#pragma arm section code = ".ARM.__at_0x20000000"
//#pragma clang section text = ".ARM.__at_0x20000000"   //AC6
int main(void)
{     
    unsigned int errCnt = 65535;
    unsigned int tMs;
    
    system_init();
    while(1)
    {
        switch(FlashParameter.status)
        {
            case FLASH_PROGRAM:
                flash_program();                 
                return(0);
                //break;
                    
            case FLASH_ERASE_PAGE:
                flash_erasepage();
                return(0);
                //break; 
                    
            case FLASH_CHIP_ERASE:
                flash_erasechip();               
                return(0);
                //break; 
              
            default:
                tMs = 65535;
                while(tMs--);
                break;
        }
        if(errCnt > 0) errCnt--;
        else           return(1);
    }
}
#pragma arm section
//#pragma clang section

最近编辑记录 wm20031015 (2022-06-27 13:52:14)

离线

#1 2022-06-30 13:58:40

上海航芯FAEEEEE
会员
注册时间: 2022-06-23
已发帖子: 8
积分: 108

Re: 上海航芯ACM32F403RET7开发板试用

Trace32我没用过,不过一般在MDK里面开发的时候都是选用Cortex-M33内核的

离线

楼主 #2 2022-07-30 20:51:15

wm20031015
会员
注册时间: 2017-10-18
已发帖子: 66
积分: 170

Re: 上海航芯ACM32F403RET7开发板试用

周六得空,把板子翻出来把坑填完,终于可以正常烧写仿真了。

acm32f4_config.h

#ifndef	__ACM32F4__H
#define __ACM32F4__H

#define CHIP_FLASH_SIZE     0x7ffff
#define FLASH_PAGE_SIZE     0x200

#define SCU_RCR             *(unsigned int *)(0x40010800UL + 0x00)  
#define SCU_CCR1            *(unsigned int *)(0x40010800UL + 0x10) 
#define SCU_CCR2            *(unsigned int *)(0x40010800UL + 0x14)
#define SCU_RCHCR           *(unsigned int *)(0x40010800UL + 0x24) 

#define SCU_RCR_REMAP_IMP   (1UL << 16)
#define SCU_RCHCR_RCHRDY    (1UL << 9)
#define SCU_RCHCR_RCH_EN    (1UL << 0)
#define SCU_RCHCR_RCH_DIV   (1UL << 8)
#define SCU_CCR2_DIVDONE    (1UL << 31)

#define EFC_CTRL            *(unsigned int *)(0x00100000UL + 0x00)
#define EFC_SEC             *(unsigned int *)(0x00100000UL + 0x04)
#define EFC_TERASE          *(unsigned int *)(0x00100000UL + 0x0c)
#define EFC_TPROG           *(unsigned int *)(0x00100000UL + 0x10)
#define EFC_STATUS          *(unsigned int *)(0x00100000UL + 0x14)   
#define EFC_INTSTATUS       *(unsigned int *)(0x00100000UL + 0x18)   
#define EFC_INTEN           *(unsigned int *)(0x00100000UL + 0x2C)    
#define FMC_FLSTS_OVF_Msk   0x01
#define SCB_VTOR           *(unsigned int *)(0xE000E000UL + 0x0D00UL + 0x08)

#define EFC_CTRL_PAGE_ERASE_MODE        (1 << 1)
#define EFC_CTRL_PROGRAM_MODE           (1 << 0)

#define EFC_STATUS_NVR4_LOCK            (1 << 4)
#define EFC_STATUS_NVR3_LOCK            (1 << 3)
#define EFC_STATUS_NVR2_LOCK            (1 << 2)
#define EFC_STATUS_NVR1_LOCK            (1 << 1)
#define EFC_STATUS_EFLASH_RDY           (1 << 0)

//计算编程等待时间,默认时钟为64M
#define SYS_CLK             (64)
#define FLASH_PROG_DELAY    (12 * SYS_CLK)
#define FLASH_ERSAE_DELAY   (6 * 1000 * SYS_CLK)

//系统时钟配置
#define system_init()   do{                 \
    SCU_RCR |= SCU_RCR_REMAP_IMP;           \
    EFC_CTRL = (EFC_CTRL & ~(0x1F << 7)) | (8 << 7); \
    if(0 == (SCU_RCHCR & SCU_RCHCR_RCH_EN)) \
    {                                       \
        SCU_RCHCR |=  SCU_RCHCR_RCH_EN;     \
        while(0 == (SCU_RCHCR & SCU_RCHCR_RCHRDY)); \
    }                                       \
    SCU_CCR1 = 0;                           \
    SCU_RCHCR &= (~SCU_RCHCR_RCH_DIV);      \
    while(0 == (SCU_RCHCR & SCU_RCHCR_RCHRDY));    \
    SCU_CCR2 = 0x0000;                      \
    while((SCU_CCR2 & SCU_CCR2_DIVDONE) == 0x00);  \
    EFC_TPROG = FLASH_PROG_DELAY;           \
    EFC_TERASE = FLASH_ERSAE_DELAY;         \
}while(0)

#define flash_readywait(value)  do{     \
    unsigned int x;                     \
    x = value;                          \
    do{                                 \
        x --;                           \
        if((EFC_STATUS & EFC_STATUS_EFLASH_RDY) != 0) break; \
    }while(x);                          \
}while(0)

#define flash_program()    do{                  \
    unsigned int i;                             \
    EFC_CTRL |= EFC_CTRL_PROGRAM_MODE;          \
    for(x=0; x<FlashParameter.size; x += 4)     \
    {                                           \
        EFC_SEC = 0x55AAAA55;                   \
        *(unsigned int *)(FlashParameter.addr + x) = *((unsigned int *)(&FlashParameter.data[x])); \
        flash_readywait(FLASH_PROG_DELAY);      \
    }                                           \
    EFC_CTRL &= ~EFC_CTRL_PROGRAM_MODE;         \
    FlashParameter.status = 0;                  \
}while(0)

#define flash_erasepage()   do{                 \
    EFC_CTRL |= EFC_CTRL_PAGE_ERASE_MODE;       \
    EFC_SEC = 0x55AAAA55;                       \
    *(unsigned int *) FlashParameter.addr = 0x00; \
    flash_readywait(FLASH_ERSAE_DELAY);         \
    EFC_CTRL &= ~EFC_CTRL_PAGE_ERASE_MODE;      \
    FlashParameter.status = 0;                  \
}while(0)

#define flash_erasechip()   do{                 \
    unsigned int x;                             \
    EFC_CTRL |= EFC_CTRL_PAGE_ERASE_MODE;       \
    for(x=0; x<FlashParameter.size; x += FLASH_PAGE_SIZE)   \
    {                                           \
        EFC_SEC = 0x55AAAA55;                   \
        *(unsigned int *)(x) = 0x00;            \
        flash_readywait(FLASH_ERSAE_DELAY);     \
    }                                           \
    EFC_CTRL &= ~EFC_CTRL_PAGE_ERASE_MODE;      \
    FlashParameter.status = 0;                  \
}while(0)

#endif

main.c

//***********************************************************************************************************
//  Ver 1.0
//      2022.04.02  1、新建文件。
//***********************************************************************************************************
//#include    "gd32l23x_config.h"
//#include    "bat32g135_config.h"
#include    "acm32f4_config.h"

//参数块定义
typedef struct{
    unsigned int  flashaddr;  //0x800,芯片起始地址
    unsigned int  flashwidth; //0x804,1=8bit,2=16bit,4=32bit
    unsigned int  width;      //0x808,数据总线位宽
    unsigned int  offset;     //0x80c,
    unsigned int  addr;       //0x810,FLASH操作地址
    unsigned int  size;       //0x814,擦除、写入字节数
    unsigned int  reserved;   //0x818,
    unsigned int  status;     //0x81c,in: 1=program, 2=erase, 5=chip erase, out: 0=o.k., 0x100=fail
    unsigned char   data[4096]; //0x820,缓冲区起始地址
}FlashParameter_Str;

static FlashParameter_Str FlashParameter __attribute__((at(0x20000800)));
//static FlashParameter_Str FlashParameter __attribute__((section(".ARM.__at_0x20000800")));

enum{
    FLASH_PROGRAM       = 0x01,
    FLASH_ERASE_PAGE    = 0x02,
    FLASH_CHIP_ERASE    = 0x05,
};

#pragma arm section code = ".ARM.__at_0x20000000"
//#pragma clang section text = ".ARM.__at_0x20000000"   //AC6
int main(void)
{     
    unsigned int errCnt = 65535;
    unsigned int tMs;
    
    system_init();
    while(1)
    {
        switch(FlashParameter.status)
        {
            case FLASH_PROGRAM:
                flash_program();                 
                return(0);
                //break;
                    
            case FLASH_ERASE_PAGE:
                flash_erasepage();
                return(0);
                //break; 
                    
            case FLASH_CHIP_ERASE:
                flash_erasechip();               
                return(0);
                //break; 
              
            default:
                tMs = 65535;
                while(tMs--);
                break;
        }
        if(errCnt > 0) errCnt--;
        else           return(1);
    }
}
#pragma arm section
//#pragma clang section

离线

楼主 #3 2022-07-30 20:53:05

wm20031015
会员
注册时间: 2017-10-18
已发帖子: 66
积分: 170

Re: 上海航芯ACM32F403RET7开发板试用

trace32 烧写的脚本 :

//连接MCU
SYStem.Down
SYStem.RESetOut
WAIT.500ms
SYStem.RESet
SYStem.CPU CortexM33
;SYStem.CPU Star
SYStem.JtagClock 30M
SYStem.CONFIG.DEBUGPORTTYPE SWD
SYStem.Option.DUALPORT ON
SYStem.Up

PRIVATE &i
&i=0x20000000
WHILE (&i<0x20001000)
(
  Data.Set &i 0
  &i=&i+1
)

FLASH.RESet
;Data.LOAD.Binary ~~/demo/arm/flash/word/acm32f4.bin 0x20000000
;Register.Set PC 0x20000004
;Go

//创建FLASH列表,64K,地址范围:0x00--0xffff,扇区大小:512byte,总线位宽:字,32位
;FLASH.Create 1. 0x0000--0x1fff 0x200 TARGET Long
FLASH.Create 1. 0x0000--0xffff 0x200 TARGET Long
;FLASH.Create 1. 0x0000--0x7ffff 0x200 TARGET Long

//bat32g13x编程程序加载到0x20000000,
FLASH.TARGET 0x20000000 0x20000800 0x200 ~~/demo/arm/flash/word/acm32f4.bin

//擦除FLASH
FLASH.Erase 1.

;编程FLASH
FLASH.Program 1.
Data.LOAD.auto F:\Project\demo\ACM32F4_ModulesDemo_Rev1.0.8\ModulesDemo\GPIO\demo\MDK_Project\Objects\Project.axf /path F:\Project\demo\ACM32F4_ModulesDemo_Rev1.0.8\ModulesDemo\GPIO\demo\MDK_Project\Objects
FLASH.Program off

List
Break

离线

#4 2022-07-31 19:23:13

muzhi
会员
注册时间: 2019-12-14
已发帖子: 39
积分: 35.5

Re: 上海航芯ACM32F403RET7开发板试用

大佬的Trace32自己买的?有便宜的购买渠道吗

离线

楼主 #5 2022-07-31 21:39:49

wm20031015
会员
注册时间: 2017-10-18
已发帖子: 66
积分: 170

Re: 上海航芯ACM32F403RET7开发板试用

搞的山寨版,

离线

楼主 #6 2022-12-31 09:26:43

wm20031015
会员
注册时间: 2017-10-18
已发帖子: 66
积分: 170

Re: 上海航芯ACM32F403RET7开发板试用

acm32f4.pngacm32f41.png

lauterbach最新发布的svdconverter终于可以完整的把SVD文件转换成per文件了,调试MCU就可以使用per.view xxxx来加载,直接察看操作寄存器了。

svd_converter.rar

离线

楼主 #7 2022-12-31 09:34:34

wm20031015
会员
注册时间: 2017-10-18
已发帖子: 66
积分: 170

Re: 上海航芯ACM32F403RET7开发板试用

acm32f42.png

实际加载后如图

离线

#8 2023-10-13 10:21:29

演技担当黄晓明
会员
注册时间: 2017-10-17
已发帖子: 184
积分: 122.5

Re: 上海航芯ACM32F403RET7开发板试用

跟着大佬走
打劫,把工程贴上来

最近编辑记录 演技担当黄晓明 (2023-10-13 11:23:41)

离线

#9 2023-12-23 15:34:44

木偶
会员
注册时间: 2023-12-23
已发帖子: 2
积分: 2

Re: 上海航芯ACM32F403RET7开发板试用

下载算法需要用什么建立工程呢,Keil可以吗,sct文件需要怎么写呢

离线

#10 2024-03-28 19:45:12

chran12345
会员
注册时间: 2024-03-28
已发帖子: 6
积分: 1

Re: 上海航芯ACM32F403RET7开发板试用

@wm20031015
how to compiler

离线

#11 2024-03-28 19:58:22

weiyu3497893153
会员
注册时间: 2024-03-28
已发帖子: 1
积分: 1

Re: 上海航芯ACM32F403RET7开发板试用

第一次来到这个论坛,感觉这个论坛很干干净净。

离线

楼主 #12 2024-03-28 20:10:11

wm20031015
会员
注册时间: 2017-10-18
已发帖子: 66
积分: 170

Re: 上海航芯ACM32F403RET7开发板试用

chran12345 说:

@wm20031015
how to compiler

keil mdk ac5

离线

楼主 #13 2024-03-28 20:32:08

wm20031015
会员
注册时间: 2017-10-18
已发帖子: 66
积分: 170

Re: 上海航芯ACM32F403RET7开发板试用

trace32_flash_20220730.rar

这是参考的工程

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn