Change clock from 12 to 25.

This commit is contained in:
Colin 2025-04-06 19:47:55 +08:00
parent 2877350489
commit c6d2b351df
5 changed files with 89 additions and 3 deletions

View File

@ -3,7 +3,7 @@
#include "tb_cxxrtl_io.h"
#include "uart.h"
#define CLK_FREQ_MHZ 12
#define CLK_FREQ_MHZ 25
// __attribute__((optimize("O0")))
int main() {

View File

@ -44,6 +44,9 @@ $(BUILD_DIR)/soc.svf : $(BUILD_DIR)/soc.bit
prog: $(BUILD_DIR)/soc.bit
ecpdap program $(BUILD_DIR)/soc.bit
# prog: ${TARGET}.svf
# ./dapprog blink.svf
flash: $(BUILD_DIR)/soc.bit
ecpdap flash write $(BUILD_DIR)/soc.bit

View File

@ -0,0 +1,29 @@
#
# Buspirate with OpenOCD support
#
# http://dangerousprototypes.com/bus-pirate-manual/
#
# http://www.fabienm.eu/flf/15-ecp5-board-kit/
# https://github.com/Martoni/blp/tree/master/platforms/colorlight
# https://github.com/HarmonInstruments/JTAG_SWD
adapter driver cmsis-dap
transport select jtag
adapter speed 10
# jtag newtap ecp5 tap -irlen 8 -expected-id 0x41111043
#LFE5U-25F 0x41111043
#LFE5U-45F 0x41112043
jtag newtap ecp5 tap -irlen 8
#init
#scan_chain
#
#svf -tap ecp5.tap -quiet -progress blink.svf
#exit
# this depends on the cable, you are safe with this option
#reset_config srst_only

54
test/sim/soc_cxxrtl/dapprog Executable file
View File

@ -0,0 +1,54 @@
#!/bin/bash
if [ ${#1} -eq 0 ]; then
echo "usage: dapprog xxx.bit or xxx.svf"
exit 0
fi
CURRENT_DIR=$(cd $(dirname $0); pwd)
CONFIG=${CURRENT_DIR}/cmsisdap.cfg
if [ "$1" == "--probe" ] || [ "$1" == "-p" ]; then
#probe add -d4 for detail log
sudo openocd -f ${CONFIG} -c \
" init;
scan_chain;
exit;
"
exit $?
else
# program
IMAGE_FILE=$1
EXT="${IMAGE_FILE##*.}"
echo EXT: $EXT
#flash write_image erase xxx.hex;
#flash write_image erase xxx.bin 0x08000000;
if [ "${EXT}" == "svf" ]; then
TARGET="$IMAGE_FILE"
elif [ "${EXT}" == "bit" ]; then
NAME="${IMAGE_FILE%%.bit}"
#/home/pi/oss/ulx3s/tools/ujprog/ujprog -j SRAM ${IMAGE_FILE} > ${NAME}_sram.svf
${CURRENT_DIR}/ujprog.bit2svf -j FLASH ${IMAGE_FILE} > ${NAME}_flash.svf
TARGET="${NAME}_flash.svf"
else
echo "illegal suffix [$EXT]"
exit 1
fi
echo "TARGET: ${TARGET}"
sudo openocd -f ${CONFIG} -c \
" init;
scan_chain;
svf -tap ecp5.tap -quiet -progress ${TARGET};
exit;
"
exit $?
fi

View File

@ -341,9 +341,9 @@ int main(int argc, char **argv) {
}
}
// 12Mhz -> 9600 = 1250
// 25Mhz -> 9600 = 2604
// SoftUartHandler must call in interrupt every 0.2*(1/BR)
if (uart_sample_count >= (1250 / 5)) {
if (uart_sample_count >= (2604 / 5)) {
// if (top.p_uart__tx.get<bool>())
// printf("1");
// else