Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include ../imports.mak
SUBDIRS := \
custom_frequency_generator empty empty_c \
fft/split_radix_fft_4k_single_core fft/split_radix_fft_post_processing \
LCD_interface logic_scope pru_emif pru_eqep pru_i2s spi_loopback \
LCD_interface logic_scope mirror_input pru_emif pru_eqep pru_i2s spi_loopback \
fir multicore_scheduler rpmsg_echo_linux

# "make" or "make all" builds projects that match $(DEVICE) set in imports.mak
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This example.projectspec file is for PRU projects written in assembly -->
<projectSpec>
<applicability>
<when>
<context
deviceFamily="PRU"
deviceId="AM263Px"
/>
</when>
</applicability>

<project
title="mirror_input"
name = "mirror_input_am263px-lp_icss_m0_pru0_fw_ti-pru-cgt"
products="com.ti.OPEN_PRU"
configurations="
Release,
Debug,
"
connection="TIXDS110_Connection.xml"
toolChain="TI"
cgtVersion="2.3.3"
device="AM263Px"
deviceCore="ICSSM_PRU_0"
ignoreDefaultDeviceSettings="true"
ignoreDefaultCCSSettings="true"
endianness="little"
outputFormat="ELF"
outputType="executable"

compilerBuildOptions="
-I${CG_TOOL_ROOT}/include
-I${OPEN_PRU_PATH}/source
-I${OPEN_PRU_PATH}/source/firmware/common
-I${OPEN_PRU_PATH}/source/include
-I${OPEN_PRU_PATH}/source/include/am263px
-DPRU0
-DSLICE0
-v3
-DSOC_AM263PX
-O2
"
linkerBuildOptions="
-m=mirror_input.${ConfigName}.map
--disable_auto_rts
--entry_point=main
--diag_suppress=10063-D
--warn_sections
--reread_libs
--diag_warning=225
--ram_model
"

postBuildStep="
$(CG_TOOL_ROOT)/bin/hexpru --diag_wrap=off --array --array:name_prefix=PRU0Firmware -o ../pru0_load_bin.h ${BuildArtifactFileBaseName}.out;
"

description="A mirror_input FW project">

<configuration name="Debug"
compilerBuildOptions="
-D_DEBUG_=1
"
linkerBuildOptions="
"
></configuration>
<configuration name="Release"
compilerBuildOptions="
"
linkerBuildOptions="
"
></configuration>
<pathVariable name="OPEN_PRU_PATH" path="${COM_TI_OPEN_PRU_INSTALL_DIR}" scope="project" />
<file path="../../../main.asm" openOnCreation="false" excludeFromBuild="false" action="copy">
</file>
<file path="./linker.cmd" openOnCreation="false" excludeFromBuild="false" action="copy">
</file>
</project>
</projectSpec>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* AM263Px_PRU0.cmd
*
* Example Linker command file for linking assembly programs built with the TI-PRU-CGT
* on AM263Px PRU0 cores
*/

/* Specify the System Memory Map */
MEMORY
{
PAGE 0:
/* 16 KB PRU Instruction RAM */
PRU_IMEM : org = 0x00000000 len = 0x00004000

PAGE 1:
/* Data RAMs */
/* 8 KB PRU Data RAM 0 */
PRU0_DMEM_0 : org = 0x00000000 len = 0x00002000
/* 8 KB PRU Data RAM 1 */
PRU1_DMEM_1 : org = 0x00002000 len = 0x00002000

PAGE 2:
/* C28 needs to be programmed to point to SHAREDMEM, default is 0 */
/* 32 KB PRU Shared RAM */
PRU_SHAREDMEM : org = 0x00010000 len = 0x00008000
}

/* Specify the sections allocation into memory */
SECTIONS {

.text > PRU_IMEM, PAGE 0
.stack > PRU0_DMEM_0, PAGE 1
.bss > PRU0_DMEM_0, PAGE 1
.cio > PRU0_DMEM_0, PAGE 1
.data > PRU0_DMEM_0, PAGE 1
.switch > PRU0_DMEM_0, PAGE 1
.sysmem > PRU0_DMEM_0, PAGE 1
.cinit > PRU0_DMEM_0, PAGE 1
.rodata > PRU0_DMEM_0, PAGE 1
.rofardata > PRU0_DMEM_0, PAGE 1
.farbss > PRU0_DMEM_0, PAGE 1
.fardata > PRU0_DMEM_0, PAGE 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
export OPEN_PRU_PATH?=$(abspath ../../../../../..)
include $(OPEN_PRU_PATH)/imports.mak

# Define build outputs
OUTPUT_NAME := mirror_input_am263px-lp_icss_m0_pru0_fw

# MCU+ projects: rename & move hex array output
MCU_HEX_NAME := pru0_load_bin.h
HEX_ARRAY_PREFIX := PRU0Firmware
MCU_HEX_PATH := $(OPEN_PRU_PATH)/examples/mirror_input/firmware/am263px-lp/$(MCU_HEX_NAME)

# which directories to search for assembly & C source files?
FILES_PATH := .. ../../.. .

# Linker command file
COMMAND_FILES := linker.cmd

# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG)
PRU_VERSION := 3
EXPECTED_DEVICE := am263px

# Default values are defined in pru_rules.mak:
# - include paths (INCLUDE)
# - compiler flags (CFLAGS)
# - linker flags (LFLAGS)

# Optional:
# Pre-define here to override default value
# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT

# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles
include $(OPEN_PRU_PATH)/pru_rules.mak

# Optional:
# Append values to INCLUDE, CFLAGS, or LFLAGS here.
# Values can be appended like this:
# INCLUDE += --include_path=<value>

# Defines (pass instance specific definitions to the program)
# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide'
# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1:
# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1
DFLAGS :=

# Libraries
# see --library in 'PRU Optimizing C/C++ Compiler User's Guide'
LIBS :=

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export OPEN_PRU_PATH?=$(abspath ../../../../../..)
include $(OPEN_PRU_PATH)/imports.mak

PROFILE?=Release

PROJECT_NAME=mirror_input_am263px-lp_icss_m0_pru0_fw_ti-pru-cgt

all:
$(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE)

clean:
$(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean

export:
$(MKDIR) $(OPEN_PRU_PATH)/ccs_projects
$(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full
63 changes: 63 additions & 0 deletions examples/mirror_input/firmware/main.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
; SPDX-License-Identifier: BSD-3-Clause
; Copyright (C) 2024-2025 Texas Instruments Incorporated - http://www.ti.com/

;***************************************************************************************
; File: main.asm
;
; Brief: mirror_input example assembly file (asm) that mirrors input signals to output pins
;
; Steps to build :
;
; - Using ccs:
; - Import pru project to ccs workspace
; - main.asm file gets copied to ccs workspace
; - Modify main.asm file
; - Build the pru project, after which .out (Executable output file) and .h (Firmware header) files gets generated
; - Either .out (Executable output file) can be loaded to PRU using ccs or R5F can write to PRU IRAM using PRUICSS driver
; - Using makefile:
; - Use command gmake -all to build PRU project
;
;***************************************************************************************

; CCS/makefile specific settings
.retain ; Required for building .out with assembly file
.retainrefs ; Required for building .out with assembly file

.global main
.sect ".text"

;********
;* MAIN *
;********

EPWM_SIGNAL .set 2 ;EPWM signal comes to GPI2
CMP_SIGNAL .set 0 ;CMP signal comes to GPI0
ICL_SIGNAL .set 1 ;ICL signal comes to GPI1

main:
; check GPI00 and set/clear GPO1 based on it
; EPWM signal is coming on GPI2
; clear r30 also so PRU0 GPO0 always starts at low
zero &r0,124
Comment thread
a1248924 marked this conversation as resolved.
Resolved
high_pulse:
Comment thread
a1248924 marked this conversation as resolved.
Resolved
Comment thread
a1248924 marked this conversation as resolved.
Resolved
; when EPWM becomes high, copy input -> output
wbs r31, EPWM_SIGNAL
; move CMP input to ICL output
qbbs bit_set0, r31,CMP_SIGNAL
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
Resolved
bit_clear0:
clr r30, r30, ICL_SIGNAL
qba low_pulse
bit_set0:
set r30, r30, ICL_SIGNAL
Comment thread
a1248924 marked this conversation as resolved.
Resolved

low_pulse:
; when EPWM becomes low, again copy input -> output
wbc r31, EPWM_SIGNAL
; move CMP input to ICL output
qbbs bit_set1, r31,CMP_SIGNAL
bit_clear1:
clr r30, r30, ICL_SIGNAL
qba high_pulse
bit_set1:
set r30, r30, ICL_SIGNAL
qba high_pulse
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
90 changes: 90 additions & 0 deletions examples/mirror_input/images/mirror_input_flow.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<mxfile host="app.diagrams.net">
<diagram name="mirror_input flow" id="mirror-input-flow">
<mxGraphModel dx="800" dy="600" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="850" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />

<mxCell id="boot" value="Start up&lt;br&gt;&lt;font style=&quot;font-size: 10px&quot; face=&quot;monospace&quot; color=&quot;#666666&quot;&gt;zero &amp;amp;r0,124&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="320" y="40" width="220" height="60" as="geometry" />
</mxCell>

<mxCell id="high_pulse" value="Wait for EPWM to go HIGH&lt;br&gt;&lt;font style=&quot;font-size: 10px&quot; face=&quot;monospace&quot; color=&quot;#666666&quot;&gt;wbs r31, EPWM_SIGNAL&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;" vertex="1" parent="1">
<mxGeometry x="290" y="140" width="260" height="70" as="geometry" />
</mxCell>

<mxCell id="qbbs1" value="Is CMP high?&lt;br&gt;&lt;font style=&quot;font-size: 10px&quot; face=&quot;monospace&quot; color=&quot;#666666&quot;&gt;qbbs bit_set0, r31, CMP_SIGNAL&lt;/font&gt;" style="rhombus;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1">
<mxGeometry x="300" y="250" width="240" height="100" as="geometry" />
</mxCell>

<mxCell id="clr0" value="Drive ICL LOW&lt;br&gt;&lt;font style=&quot;font-size: 10px&quot; face=&quot;monospace&quot; color=&quot;#666666&quot;&gt;clr r30, r30, ICL_SIGNAL&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;" vertex="1" parent="1">
<mxGeometry x="120" y="390" width="220" height="60" as="geometry" />
</mxCell>

<mxCell id="set0" value="Drive ICL HIGH&lt;br&gt;&lt;font style=&quot;font-size: 10px&quot; face=&quot;monospace&quot; color=&quot;#666666&quot;&gt;set r30, r30, ICL_SIGNAL&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;" vertex="1" parent="1">
<mxGeometry x="500" y="390" width="220" height="60" as="geometry" />
</mxCell>

<mxCell id="low_pulse" value="Wait for EPWM to go LOW&lt;br&gt;&lt;font style=&quot;font-size: 10px&quot; face=&quot;monospace&quot; color=&quot;#666666&quot;&gt;wbc r31, EPWM_SIGNAL&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;" vertex="1" parent="1">
<mxGeometry x="290" y="500" width="260" height="70" as="geometry" />
</mxCell>

<mxCell id="qbbs2" value="Is CMP high?&lt;br&gt;&lt;font style=&quot;font-size: 10px&quot; face=&quot;monospace&quot; color=&quot;#666666&quot;&gt;qbbs bit_set1, r31, CMP_SIGNAL&lt;/font&gt;" style="rhombus;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1">
<mxGeometry x="300" y="610" width="240" height="100" as="geometry" />
</mxCell>

<mxCell id="clr1" value="Drive ICL LOW&lt;br&gt;&lt;font style=&quot;font-size: 10px&quot; face=&quot;monospace&quot; color=&quot;#666666&quot;&gt;clr r30, r30, ICL_SIGNAL&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;" vertex="1" parent="1">
<mxGeometry x="120" y="750" width="220" height="60" as="geometry" />
</mxCell>

<mxCell id="set1" value="Drive ICL HIGH&lt;br&gt;&lt;font style=&quot;font-size: 10px&quot; face=&quot;monospace&quot; color=&quot;#666666&quot;&gt;set r30, r30, ICL_SIGNAL&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;" vertex="1" parent="1">
<mxGeometry x="500" y="750" width="220" height="60" as="geometry" />
</mxCell>

<mxCell id="e1" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;" edge="1" parent="1" source="boot" target="high_pulse">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e2" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;" edge="1" parent="1" source="high_pulse" target="qbbs1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e3" value="No" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;" edge="1" parent="1" source="qbbs1" target="clr0">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e4" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;" edge="1" parent="1" source="qbbs1" target="set0">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e5" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;" edge="1" parent="1" source="clr0" target="low_pulse">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e6" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;" edge="1" parent="1" source="set0" target="low_pulse">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e7" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;" edge="1" parent="1" source="low_pulse" target="qbbs2">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e8" value="No" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;" edge="1" parent="1" source="qbbs2" target="clr1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e9" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;" edge="1" parent="1" source="qbbs2" target="set1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e10" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;exitX=0;exitY=0.5;entryX=0;entryY=0.5;" edge="1" parent="1" source="clr1" target="high_pulse">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="60" y="780" />
<mxPoint x="60" y="175" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="e11" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;exitX=1;exitY=0.5;entryX=1;entryY=0.5;" edge="1" parent="1" source="set1" target="high_pulse">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="800" y="780" />
<mxPoint x="800" y="175" />
</Array>
</mxGeometry>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/mirror_input/images/truth_table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading