PICSim  0.8.1
PICsim - PIC Simulator

Introduction

This is the documentation of using the picsim simulation library functions.

Library functions usage simple example

Demonstration of a simple example of using picsim library functions

picsim_simple.c

#include<picsim/picsim.h>
#include<stdio.h>
int main()
{
int i;
unsigned char val;
//microcontroller object
_pic pic1;
//set serial port
pic_set_serial(&pic1,"/dev/tnt2",0,0,0);
//pic_set_serial(&pic1,"COM2",0,0,0);
//initialization and program loading
pic_init(&pic1, P16F628A, "../../../examples/shift/shift.hex",1,20e6);
//enable print messages of internal instruction execution (slow down the simulation speed)
pic1.print=1;
//loop
for(i=0;i<1000;i++)
{
//execute one instruction cycle
//read digital pin 1
val=pic_get_pin(1);
//write digital pin 2
pic_set_pin(2, val);
}
//free internal memory
}

Makefile

CC= gcc
FLAGS= -Wall -ggdb
all: picsim_simple.c
$(CC) $(FLAGS) picsim_simple.c -o picsim_simple -lpicsim
clean:
rm -rf picsim_simple
run:
picsim_simple P16F628A ../../examples/shift.hex
pic_step
void pic_step(void)
Execute one simulation step.
_pic
PICsim PIC structure.
Definition: picsim.h:250
pic_end
void pic_end(void)
finalize and free pic object internal memory
_pic::print
unsigned char print
print information ON/OFF
Definition: picsim.h:251
pic_set_pin
int pic_set_pin(unsigned char pin, unsigned char value)
Set digital value of one pin.
pic_get_pin
unsigned char pic_get_pin(unsigned char pin)
Get digital value of one pin.
pic_init
int pic_init(_pic *pic_, int processor, const char *fname, int leeprom, float freq)
Initialize one pic object.
pic_set_serial
int pic_set_serial(_pic *pic_, int nser, const char *name, int flowcontrol, int ctspin, int rtspin)
Configure the serial port connection.