From 1ff7822b7a8a8b61318cf33c37f662d3c5665cb8 Mon Sep 17 00:00:00 2001 From: lcgamboa Date: Sat, 14 Sep 2024 14:35:29 -0300 Subject: [PATCH] docs examples updated --- .github/workflows/build.yml | 2 +- docs/examples/realtime/Makefile | 15 +++++ docs/examples/realtime/realtime.c | 72 +++++++++++++++++++++++ docs/examples/simple_use/Makefile | 3 - docs/examples/simple_use/picsim_simple | Bin 27840 -> 0 bytes docs/examples/simple_use/picsim_simple.c | 12 ++-- 6 files changed, 94 insertions(+), 10 deletions(-) create mode 100644 docs/examples/realtime/Makefile create mode 100644 docs/examples/realtime/realtime.c delete mode 100755 docs/examples/simple_use/picsim_simple diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7fc0a22..01e8481 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: Build picsim on: [push] jobs: build-macos: - runs-on: macos-11 + runs-on: macos-12 steps: - uses: actions/checkout@v2 - name: Build diff --git a/docs/examples/realtime/Makefile b/docs/examples/realtime/Makefile new file mode 100644 index 0000000..2933dec --- /dev/null +++ b/docs/examples/realtime/Makefile @@ -0,0 +1,15 @@ + +CC= gcc + +FLAGS= -ggdb -Wall + +all: realtime + +realtime: realtime.c + $(CC) $(FLAGS) realtime.c -o realtime -lpicsim + +clean: + rm -rf realtime + + + diff --git a/docs/examples/realtime/realtime.c b/docs/examples/realtime/realtime.c new file mode 100644 index 0000000..582e25d --- /dev/null +++ b/docs/examples/realtime/realtime.c @@ -0,0 +1,72 @@ + +#include +#include +#include +#include +#include +#include + + +#define FREQ 4000000L + +static _pic pic1; + +void timer_callback(int signum) +{ + unsigned char PORTB; + static unsigned char PORTB_old; + const unsigned int nsteps = 100e-3 / (4.0 / pic1.freq); + for (int i = 0; i < nsteps; i++) + { + pic_step(&pic1); + + //READ pins + // PORTB |= pic_get_pin(&pic1, 6); + // use direct access instead pic_get_pin to speed up + + PORTB = 0; + PORTB |= pic1.pins[6 - 1].value; // RB0 + PORTB |= pic1.pins[7 - 1].value << 1; // RB1 + PORTB |= pic1.pins[8 - 1].value << 2; // RB2 + PORTB |= pic1.pins[9 - 1].value << 3; // RB3 + PORTB |= pic1.pins[10 - 1].value << 4; // RB4 + PORTB |= pic1.pins[11 - 1].value << 5; // RB5 + PORTB |= pic1.pins[12 - 1].value << 6; // RB6 + PORTB |= pic1.pins[13 - 1].value << 7; // RB7 + + if (PORTB != PORTB_old) + { + PORTB_old = PORTB; + printf("PORTB =0x%02X\n", PORTB); + } + } +} + +void ctrlc_callback(int signum) +{ + printf("end\n"); + pic_end(&pic1); + exit(0); +} + +int main() +{ + + pic_init(&pic1, getprocbyname("PIC16F628A"), "../../../examples/shift/shift.hex", 1, FREQ); + + struct itimerval new_timer; + struct itimerval old_timer; + + new_timer.it_value.tv_sec = 0; + new_timer.it_value.tv_usec = 100 * 1000; //100ms + new_timer.it_interval.tv_sec = 0; + new_timer.it_interval.tv_usec = 100 * 1000; //100ms + + setitimer(ITIMER_REAL, &new_timer, &old_timer); + signal(SIGALRM, timer_callback); + signal(SIGINT, ctrlc_callback); + + // Waitting forever + while (sleep(10)) + ; +} diff --git a/docs/examples/simple_use/Makefile b/docs/examples/simple_use/Makefile index 0cc62a0..7283b12 100644 --- a/docs/examples/simple_use/Makefile +++ b/docs/examples/simple_use/Makefile @@ -9,8 +9,5 @@ all: picsim_simple.c clean: rm -rf picsim_simple -run: - picsim_simple P16F628A ../../examples/shift.hex - diff --git a/docs/examples/simple_use/picsim_simple b/docs/examples/simple_use/picsim_simple deleted file mode 100755 index 9f99030cc37e853606dd55200ecc754158232f61..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 27840 zcmeHwd3YSfwQqG-w>56rl8iSQ6Ff4@6^pgm7_k_%+9Qx{A;};JFdof}7A$E7&B&J7 zB4R@9fQeW_L|yBQ$K9d>?kwWfZ#~=)%!=ysj19C1hG)_-%)pnTF z(s~rLT*UQ4QV-(?$za))c6xV z!QXbRFFmcI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