本帖最后由 Jekele 于 2021-2-24 16:46 编辑
开发板年前就收到了,包装完好,白色。演值颇高,自带AT-Link硬件仿真,这点非常棒,只要一根数据线就OK了。
资源方面也要优于老牌STM32 MCU ,工作频率能达到最大240 MHz,224K RAM + 1M ROM存储不需要担心不够用。可谓是国产之光。
使用MDK5编写了点灯和SPIM的DEMO用来小测一番。 注:在使用SPIM外设时要把JP8的跳线帽从普通IO换成SPIM模式。负责不能使用。
1、LED
void LED_GPIOInit(void)
{
GPIO_InitType GPIO_InitStruce;
//时钟使能
RCC_APB2PeriphClockCmd(RCC_APB2PERIPH_GPIOD,ENABLE);
//PD13 LED2
GPIO_InitStruce.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;
GPIO_InitStruce.GPIO_Mode = GPIO_Mode_OUT_PP;
GPIO_InitStruce.GPIO_Pins = GPIO_Pins_13;
GPIO_Init(GPIOD, &GPIO_InitStruce);
//PD14 LED3
GPIO_InitStruce.GPIO_Pins = GPIO_Pins_14;
GPIO_Init(GPIOD, &GPIO_InitStruce);
//PD15 LED4
GPIO_InitStruce.GPIO_Pins = GPIO_Pins_15;
GPIO_Init(GPIOD, &GPIO_InitStruce);
GPIO_SetBits(GPIOD,GPIO_Pins_13);
GPIO_SetBits(GPIOD,GPIO_Pins_14);
GPIO_SetBits(GPIOD,GPIO_Pins_15);
}
void LED_Light(void)
{
LEDALL_ON;
delay_ms(1000);
LEDALL_OFF;
delay_ms(1000);
LEDALL_ON;
delay_ms(1000);
LEDALL_OFF;
delay_ms(1000);
LEDRED_ON;
delay_ms(500);
LEDYELLOW_ON;
delay_ms(500);
LEDGREEN_ON;
delay_ms(500);
LEDALL_OFF;
delay_ms(1000);
}
2、SPIM
/**
* @brief Configures the ext.flash
* @param None
* @retval None
*/
void FLASH_InitExtFlash(void)
{
GPIO_InitType GPIO_InitStructure;
/* Enable ext.flash GPIO clock */
RCC_APB2PeriphClockCmd(RCC_APB2PERIPH_AFIO|RCC_APB2PERIPH_GPIOA|RCC_APB2PERIPH_GPIOB, ENABLE);
/* Configure ext.flash pin */
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pins = GPIO_Pins_8;
GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pins = GPIO_Pins_1|GPIO_Pins_6|GPIO_Pins_7|GPIO_Pins_10|GPIO_Pins_11;
GPIO_Init(GPIOB, &GPIO_InitStructure);
/* Select PB10, PB11 as SPIF_TX and SPIF_RX */
GPIO_PinsRemapConfig(GPIO_Remap_EXT_FLASH, ENABLE);
GPIO_PinsRemapConfig(AFIO_MAP7_SPIF_1001, ENABLE);
//解锁FLASH闪存区块3
/* In this example, use on-board EN25QH128A as ext.flash */
FLASH->B3SEL = FLASH_SPIM_TYPE2;
/* Unlock the ext.flash program erase controller */
while (BIT_READ(FLASH->STS3, FLASH_STS_BSY));
FLASH->FCKEY3 = FLASH_KEY1;
FLASH->FCKEY3 = FLASH_KEY2;
while (BIT_READ(FLASH->CTRL3, FLASH_CTRL_LCK));
/* If the data written to ext.flash need to be scrambled, please specify the scrambled range */
FLASH->DA = 0;
return;
}
/**
* @brief Read one page from a specified address in ext.flash
* @param adr: specifies the page starting address
* @param sz: page size in bytes
* @param buf: the content read from ext.flash
* @retval None
*/
void ReadPage (unsigned long adr, unsigned long sz, unsigned char *buf)
{
while (sz)
{
*(UINT32 *)buf = *(UINT32 *)adr;
sz -= sizeof(UINT32);
adr += sizeof(UINT32);
buf += sizeof(UINT32);
}
}
//不检查的写入
//WriteAddr:起始地址
//pBuffer:数据指针
//NumToWrite:半字(16位)数
void FLASH_Write_NoCheck(u32 WriteAddr,u16 *pBuffer,u16 NumToWrite)
{
u16 i;
for(i=0;i<NumToWrite;i++)
{
FLASH_ProgramHalfWord(WriteAddr,pBuffer);
WriteAddr+=2;//地址增加2.
}
}
/**
* @brief To test ext.flash
* @param None
* @retval None
*/
void SPIM_test(void)
{
u16 i=0;
/* Configures the ext.flash */
printf("init SPIM.\r\n");
FLASH_InitExtFlash();
/* Fill the content to be writed to ext.flash */
for(i=0;i<SPIM_PAGE_SIZE;i++)
{
WriteBuffer=i%256;
}
/* Erases an ext.flash page */
printf("erase one page.\r\n");
FLASH_ErasePage(SPIM_TEST_ADDR);
/* Read an ext.flash page */
memset(ReadBuffer,0,SPIM_PAGE_SIZE);
ReadPage(SPIM_TEST_ADDR, SPIM_PAGE_SIZE, ReadBuffer);
/* Check if the desired page are erased */
for(i=0;i<SPIM_PAGE_SIZE;i++)
{
if(ReadBuffer!=0xff)
{
printf("operate SPIM fail.\r\n");
return;
}
}
/* Program an ext.flash page */
printf("write one page.\r\n");
i=0;
while(i<SPIM_PAGE_SIZE)
{
FLASH_ProgramWord (SPIM_TEST_ADDR+i,*(u32 *)(WriteBuffer+i));
i=i+4;
}
/* Read an ext.flash page */
printf("read one page.\r\n");
memset(ReadBuffer,0,SPIM_PAGE_SIZE);
ReadPage(SPIM_TEST_ADDR, SPIM_PAGE_SIZE, ReadBuffer);
/* Check if reading result and writing content are the same */
printf("compare the WriteBuffer/ReadBuffer.\r\n");
for(i=0;i<SPIM_PAGE_SIZE;i++)
{
if(ReadBuffer!=WriteBuffer)
{
/* Print the ext.flash testing result */
printf("test SPIM fail.\r\n");
return;
}
}
/* Print the ext.flash testing result */
printf("test SPIM success!\r\n");
}
int main()
{
UART1_Config();
LED_GPIOInit();
printf("\r\n雅特力AT32VGT7开发板\r\n");
SPIM_test();
while(1)
{
LED_Light();
}
}
小测很成功,最后附上打印信息。
体验后板子很棒,正常能够用的外设都很全,正常情况下不需要扩展板就可以使用了。预祝雅特力为国产撑起一片天。
|