PICSim
0.8.1
PICsim - PIC Simulator
|
PICsim - PIC Simulator - API. More...
#include "p16fxxx_defs.h"
#include "p16fxxxe_defs.h"
#include "p18fxxx_defs.h"
Go to the source code of this file.
Data Structures | |
struct | picpin |
PICsim pin structure. More... | |
struct | _serial |
PICsim serial structure. More... | |
struct | _pic |
PICsim PIC structure. More... | |
struct | pic_desc |
Macros | |
#define | PICSIM |
#define | SERIAL_MAX 2 |
#define | BUFFMAX 8192 |
#define | PD_OUT 0x00 |
#define | PD_IN 0x01 |
#define | PT_CMOS 0x01 |
#define | PT_TTL 0x02 |
#define | PT_ANALOG 0x04 |
#define | PT_ANAREF 0x05 |
#define | PT_USART 0x06 |
#define | PT_NC 0xFF |
#define | P16 1 |
#define | P18 2 |
#define | P16E 3 |
#define | P16F84A 0x0560 |
#define | P16F777 0x0DE0 |
#define | P16F18855 0X306C |
#define | P18F452 0x0420 |
#define | CFG_MCLR 0x01 |
#define | CFG_WDT 0x02 |
#define | CFG_DEBUG 0x04 |
#define | CFG_WDT_DIV 0x08 |
#define | PDIP 0 |
#define | QFN 1 |
#define | HEX_OK 0 |
No erro | |
#define | HEX_NFOUND 1 |
File not found. | |
#define | HEX_CHKSUM 2 |
Checksum error. | |
#define | HEX_NWRITE 3 |
File write error. | |
#define | P_VDD &NO_IO[0] |
#define | P_VSS &NO_IO[1] |
#define | P_RST &NO_IO[2] |
#define | P_OSC &NO_IO[3] |
#define | P_USB &NO_IO[4] |
#define | P_NC &NO_IO[5] |
#define | sfr_addr(fsr) (fsr - pic->ram) |
Return the mapped address of FSR struct member More... | |
#define | PMAX 20 |
#define | init_pic(function, family, ID) |
Functions | |
int | pic_set_serial (_pic *pic_, int nser, const char *name, int flowcontrol, int ctspin, int rtspin) |
Configure the serial port connection. More... | |
int | pic_init (_pic *pic_, int processor, const char *fname, int leeprom, float freq) |
Initialize one pic object. More... | |
int | pic_reset (int flags) |
Reset the microcontroller. More... | |
void | pic_erase_flash (void) |
erase the microcontroller FLASH | |
void | pic_step (void) |
Execute one simulation step. More... | |
void | pic_end (void) |
finalize and free pic object internal memory | |
unsigned char | pic_get_pin (unsigned char pin) |
Get digital value of one pin. More... | |
int | pic_set_pin (unsigned char pin, unsigned char value) |
Set digital value of one pin. More... | |
int | pic_set_apin (unsigned char pin, float value) |
Set digital value of one pin. More... | |
unsigned char | pic_get_pin_type (unsigned char pin) |
Get type of one pin. More... | |
unsigned char | pic_get_pin_dir (unsigned char pin) |
Get dir of one pin. More... | |
unsigned char | pic_get_pin_DOV (unsigned char pin) |
Get Default Open Value of one pin (external PULL UP) More... | |
int | pic_set_pin_DOV (unsigned char pin, unsigned char value) |
Set Default Open Value of one pin (external PULL UP) More... | |
void | pic_icsp_init (void) |
Initialize P16 ICSP support. | |
int | pic_icsp (void) |
Run P16 ICSP (must be pooling) More... | |
void | pic_icsp_init18 (void) |
Initialize P18 ICSP support. | |
int | pic_icsp18 (void) |
Run P18 ICSP (must be pooling) More... | |
int | read_ihx (const char *fname, int leeprom) |
Read HEX file to P16 microcontroller. More... | |
int | read_ihx_16e (const char *fname, int leeprom) |
Read HEX file to P16E microcontroller. More... | |
int | read_ihx_18 (const char *fname, int leeprom) |
Read HEX file to P18 microcontroller. More... | |
int | write_ihx (const char *fname) |
Dump all non volatile P16 microcontroller memory to HEX file. More... | |
int | write_ihx16e (const char *fname) |
Dump all non volatile P16E microcontroller memory to HEX file. More... | |
int | write_ihx18 (const char *fname) |
Dump all non volatile P18 microcontroller memory to HEX file. More... | |
int | getproclist (char list[][30], int size) |
Return list name of supported processors More... | |
unsigned int | getprocbyname (const char *str) |
Return processor ID by name. More... | |
unsigned int | getfprocbyname (const char *str) |
Return processor family ID by name. More... | |
unsigned int | getfprocbynumber (int proc) |
Return processor family ID by ID. More... | |
char * | getnamebyproc (int proc, char *str) |
Return processor name by ID. More... | |
const char * | getFSRname_16 (unsigned int addr) |
Return P16 FSR name by address. More... | |
const char * | getFSRname_16E (unsigned int addr) |
Return P16E FSR name by address. More... | |
const char * | getFSRname_16E2 (unsigned int addr) |
Return P16E2 FSR name by address. More... | |
const char * | getFSRname_18 (unsigned int addr) |
Return P18 FSR name by address. More... | |
const char * | getPinName (_pic *pic, int pin, char *pname) |
Return pin name. More... | |
void | pic_register (pic_desc picd) |
Variables | |
unsigned char | NO_IO [6] |
_pic * | pic |
global pointer | |
pic_desc | PICS [PMAX] |
int | PIC_count |
PICsim - PIC Simulator - API.
PICsim emulates a microcontroller PIC16F84A/16F628/16F777/16F877A/18F452/18F4520/18F4550/18F4620 and periferics such as USART and timers, the simulator architecture permit easy implementation of external elements in c language.
#define init_pic | ( | function, | |
family, | |||
ID | |||
) |
#define sfr_addr | ( | fsr | ) | (fsr - pic->ram) |
unsigned int getfprocbyname | ( | const char * | str | ) |
Return processor family ID by name.
str | name of microcontoller |
unsigned int getfprocbynumber | ( | int | proc | ) |
Return processor family ID by ID.
proc | ID of microcontoller |
const char* getFSRname_16 | ( | unsigned int | addr | ) |
Return P16 FSR name by address.
addr | address of FSR |
const char* getFSRname_16E | ( | unsigned int | addr | ) |
Return P16E FSR name by address.
addr | address of FSR |
const char* getFSRname_16E2 | ( | unsigned int | addr | ) |
Return P16E2 FSR name by address.
addr | address of FSR |
const char* getFSRname_18 | ( | unsigned int | addr | ) |
Return P18 FSR name by address.
addr | address of FSR |
char* getnamebyproc | ( | int | proc, |
char * | str | ||
) |
Return processor name by ID.
proc | ID of microcontoller |
str | string to return the name of microcontroller |
const char* getPinName | ( | _pic * | pic, |
int | pin, | ||
char * | pname | ||
) |
Return pin name.
pic_ | pointer to pic object |
pin | pin number |
str | string to return the name of pin |
unsigned int getprocbyname | ( | const char * | str | ) |
Return processor ID by name.
str | name of microcontoller |
int getproclist | ( | char | list[][30], |
int | size | ||
) |
Return list name of supported processors
variable | to return the number of supported processors |
unsigned char pic_get_pin | ( | unsigned char | pin | ) |
Get digital value of one pin.
pin | pin number |
unsigned char pic_get_pin_dir | ( | unsigned char | pin | ) |
unsigned char pic_get_pin_DOV | ( | unsigned char | pin | ) |
Get Default Open Value of one pin (external PULL UP)
pin | pin number |
unsigned char pic_get_pin_type | ( | unsigned char | pin | ) |
int pic_icsp | ( | void | ) |
Run P16 ICSP (must be pooling)
int pic_icsp18 | ( | void | ) |
Run P18 ICSP (must be pooling)
int pic_init | ( | _pic * | pic_, |
int | processor, | ||
const char * | fname, | ||
int | leeprom, | ||
float | freq | ||
) |
Initialize one pic object.
Use to initialize the _pic object structure
pic_ | pointer to pic object |
processor | microcontroller ID |
fname | Name of hex file to load |
leeprom | Load EEprom from file if equal to 1 |
freq | Frequency of microcontoller |
int pic_reset | ( | int | flags | ) |
Reset the microcontroller.
Reset the microcontroller to initial state
flags | 0 = WDT reset 1 = Power on reset -1 = MCLRE pin reset |
int pic_set_apin | ( | unsigned char | pin, |
float | value | ||
) |
Set digital value of one pin.
pin | pin number |
value | pin analog value from 0 to 5 |
int pic_set_pin | ( | unsigned char | pin, |
unsigned char | value | ||
) |
Set digital value of one pin.
pin | pin number |
value | pin value 0 or 1 |
int pic_set_pin_DOV | ( | unsigned char | pin, |
unsigned char | value | ||
) |
Set Default Open Value of one pin (external PULL UP)
pin | pin number |
value | pin default value 0 or 1 |
int pic_set_serial | ( | _pic * | pic_, |
int | nser, | ||
const char * | name, | ||
int | flowcontrol, | ||
int | ctspin, | ||
int | rtspin | ||
) |
Configure the serial port connection.
Use to link the PICSim serial to one serial port
pic_ | pointer to pic object |
nser | number of serial |
name | Name of serial port |
flowcontrol | use flowcontrol |
ctspin | CTS pin if flowcontrol = 1 |
rtspin | RTS pin if flowcontrol = 1 |
void pic_step | ( | void | ) |
Execute one simulation step.
Execute one simulation step, must be call continuously to run the program in pic flash memory
int read_ihx | ( | const char * | fname, |
int | leeprom | ||
) |
Read HEX file to P16 microcontroller.
fname | name of .hex file |
leeprom | flag to load or not the microcontroller data eeprom form file |
int read_ihx_16e | ( | const char * | fname, |
int | leeprom | ||
) |
Read HEX file to P16E microcontroller.
fname | name of .hex file |
leeprom | flag to load or not the microcontroller data eeprom form file |
int read_ihx_18 | ( | const char * | fname, |
int | leeprom | ||
) |
Read HEX file to P18 microcontroller.
fname | name of .hex file |
leeprom | flag to load or not the microcontroller data eeprom form file |
int write_ihx | ( | const char * | fname | ) |
Dump all non volatile P16 microcontroller memory to HEX file.
fname | name of .hex file |
int write_ihx16e | ( | const char * | fname | ) |
Dump all non volatile P16E microcontroller memory to HEX file.
fname | name of .hex file |
int write_ihx18 | ( | const char * | fname | ) |
Dump all non volatile P18 microcontroller memory to HEX file.
fname | name of .hex file |