1947 views|2 replies

1w

Posts

16

Resources
The OP
 

[Review of Arteli Development Board AT32F421] 2. Read the MCU model [Copy link]

 

The chip has a unique number. When you look at the document, there is an introduction to reading the CORTEX model. Just look for M0, M1, M4.

Now try it:

First, choose the USART printf routine. After reading the routine, I think the key point is where the redefined function is. I searched for a long time and finally found it in at32_board.c:


#ifdef __GNUC__
  /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
     set to 'Yes') calls __io_putchar() */
  #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
  #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */

/**
  * [url=home.php?mod=space&uid=159083]@brief[/url] Retargets the C library printf function to the USART.
  * @param  None
  * @retval None
  */
PUTCHAR_PROTOTYPE
{  
  USART_SendData(AT32_PRINT_UART, ch);
  while ( USART_GetFlagStatus(AT32_PRINT_UART, USART_FLAG_TRAC) == RESET );    
  return ch;
}

Of course, you have to tick the micro library:

The following is the procedure: directly read the contents of the address.

int main(void)
{     
  /* USART1 configured as follow:
        - BaudRate = 115200 baud  
        - Word Length = 8 Bits
        - One Stop Bit
        - No parity
        - Hardware flow control disabled (RTS and CTS signals)
        - Receive and transmit enabled
  */
  UART_Print_Init(115200);

  /* Output a message on Hyperterminal using printf function */
  printf("\n\rUSART Printf Example: retarget the C library printf function to the USART\n\r");

	cortex_id = *(uint32_t *)0xE000ED00; //读取 cortex 型号
	if((cortex_id == 0x410FC240) || (cortex_id == 0x410FC241)) 
  {
    printf("This chip is Cortex-M4.\r\n");
	}
  else
  {
    printf("This chip is Other Device.\r\n");
  }
	
  while (1)
  {
  }
}

The following are the results:

This post is from Domestic Chip Exchange

Latest reply

Thanks for sharing, looking forward to the follow-up   Details Published on 2021-4-8 21:46

赞赏

1

查看全部赞赏

Personal signaturehttp://shop34182318.taobao.com/
https://shop436095304.taobao.com/?spm=a230r.7195193.1997079397.37.69fe60dfT705yr
 
 

1942

Posts

2

Resources
2
 

Can you read this? I haven't tried it yet!

This post is from Domestic Chip Exchange
 
 
 

7422

Posts

2

Resources
3
 

Thanks for sharing, looking forward to the follow-up

This post is from Domestic Chip Exchange
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list