
-
UID:1023450
-
- 注册时间2011-12-16
- 最后登录2022-04-17
- 在线时间2350小时
-
-
访问TA的空间加好友用道具
|
近来坛上红火的GD32,我也受感染,进了几个,赶紧拆了一片,并做了个最小系统(帖子论坛数据库出错,内容没了), arm的板子,跑起来确实很爽; 并 移植完成GD32F103RET6 ARDUINO GD32F103RET6 120M 和M64 16M运行速度比较测试 跑 freertos: http://bbs.mydigit.cn/read.php?tid=1589017 gd32超频到120M运行,不拿点超越stm32的东东,总觉得没有体现gd的优势, 以前我: atmega64 做个逻辑分析仪,最高速率4M,存储深度2048,开源多平台上位软件pc机显示 ,由于M64 ram小,且主频低,采样速率受到限制.如用gd则可以达到15M的速率,便马山动手,开始向gd arm移植. 还是放在arduino中开发,经排错验证,最终的完成的编译界面: 由于gd仅负责采样,其余由上位机完成,所以代码不大仅14k,ram当然用尽了. 上位机运行界面: (在单位发帖,仅简单用跳线将pa3接了地) 完整的代码: - /*
- SLLogicLogger - Simple logic analyser for Stellaris Launchpad
- SLLogicLogger supports the SUMP protocol over UART. The UART is mapped
- through the debug/flash controller on the Stellaris Launchpad to a virtual
- com port. It samples signals on PORTB with samplerate 10 Mhz, buffersize
- 16kByte, sampling starts at any change on PORTB[0..7].
- PB0 and PB1 are limited to 3.6 V! All other pins are 5 V tolerant.
- The idea for this simple analyser comes from http://jjmz.free.fr/?p=148
- Description of the SUMP protocol:
- - http://www.sump.org/projects/analyzer/protocol/
- - http://dangerousprototypes.com/docs/The_Logic_Sniffer%27s_extended_SUMP_protocol
- A multiplatform client which supports the SUMP protocol is OLS:
- http://www.lxtreme.nl/ols/
- To install device support for OLS, copy ols.profile* file into the
- ols/plugins folder.
- Copyright (C) 2012 Thomas Fischl <tfischl@gmx.de> http://www.fischl.de
- Last update: 2012-12-24
-
- for gd32f103ret6 120M f_cpu samples signals on PORTA(0..7) with samplerate 15 Mhz, buffersize
- 60kByte. by huaweiwx@sina.com 2016.3.22
- */
- #define VERSION "SLLogicLogger v0.1"
- //boards
- #define LED LED_BUILTIN //LED_BUILTIN: PC13
- // buffer size
- #define BUFFERSIZE 60*1024
- #define MAX_SAMPLERATE 15000000
- // input pa reg
- #define GPIO_PORT_DATA_R gpioa.regs->IDR
- uint8_t pin[8] ={PA0,PA1,PA2,PA3,PA4,PA5,PA6,PA7};
- // SUMP command defintions
- #define SUMP_RESET 0x00
- #define SUMP_ARM 0x01
- #define SUMP_QUERY 0x02
- #define SUMP_GET_METADATA 0x04
- // sampling buffer
- char buffer[BUFFERSIZE];
- // send 32bit unsigned integer as SUMP metadata
- void sump_sendmeta_uint32(char type, unsigned int i) {
- Serial1.write(type);
- Serial1.write((i >> 24) & 0xff);
- Serial1.write((i >> 16) & 0xff);
- Serial1.write((i >> 8) & 0xff);
- Serial1.write(i & 0xff);
- }
- // send 8bit unsigned integer as SUMP metadata
- void sump_sendmeta_uint8(char type, unsigned char i) {
- Serial1.write(type);
- Serial1.write(i);
- }
- // wait for trigger and do sampling
- void dosampling() {
- // use it as timeout for trigger
- unsigned int i = 0xfffffff;
- digitalWrite(LED,LOW);
- // get current gpio state an wait for change or timeout
- char v = GPIO_PORT_DATA_R;
- while ((i-- != 0) && (GPIO_PORT_DATA_R == v));
- // aquire data
- for (i = BUFFERSIZE-1; i != 0; i--) {
- buffer[i] = GPIO_PORT_DATA_R;
- }
- buffer[0] =GPIO_PORT_DATA_R;
- // send it over uart
- for (i = 0; i < BUFFERSIZE; i++) Serial1.write(buffer[i]);
- digitalWrite(LED,HIGH);
- }
- //init
- void setup(){
- pinMode(LED, OUTPUT);
- for (uint8_t i=0;i<8;i++) pinMode(pin[i],INPUT);
- Serial1.begin(115200);
- for(uint8_t i=0;i<7;i++){ //ready
- digitalToggle(LED);
- delay(250);
- }
- }
- // main routine
- void loop () {
- if (Serial1.available()) {
- // get the new byte:
- unsigned char cmd = Serial1.read();
- switch (cmd) {
- case SUMP_RESET:
- break;
- case SUMP_ARM:
- dosampling();
- break;
- case SUMP_QUERY:
- Serial1.print("1ALS");
- break;
- case SUMP_GET_METADATA:
- // device name
- Serial1.write(0x01);
- Serial1.print(VERSION);
- Serial1.write(0x00);
- // amount of sample memory available (bytes)
- sump_sendmeta_uint32(0x21, BUFFERSIZE);
- // maximum sample rate (hz)
- sump_sendmeta_uint32(0x23, MAX_SAMPLERATE);
- // number of usable probes (short)
- sump_sendmeta_uint8(0x40, 0x08);
- // protocol version (short)
- sump_sendmeta_uint8(0x41, 0x02);
- // end of meta data
- Serial1.write(0x00);
- break;
- // long commands.. consume bytes from uart
- case 0xC0:
- case 0xC4:
- case 0xC8:
- case 0xCC:
- case 0xC1:
- case 0xC5:
- case 0xC9:
- case 0xCD:
- case 0xC2:
- case 0xC6:
- case 0xCA:
- case 0xCE:
- case 0x80:
- case 0x81:
- case 0x82:
- Serial1.read();
- Serial1.read();
- Serial1.read();
- Serial1.read();
- break;
- }
- }
- }
源代码 编译hex和 配置文件cfg 网盘同步共享. 安装和使用及上位机,参考 : atmega64 做个逻辑分析仪,最高速率4M,存储深度2048,开源多平台上位软件pc机显示,
|