|
PICSim 0.8.1
PICsim - PIC Simulator
|
PICsim - PIC Simulator - API. More...
#include "bitbang_uart.h"#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 | ccp_t |
| PICsim pin structure. More... | |
| struct | _serial |
| PICsim serial structure. More... | |
| struct | _pic |
| struct | pic_desc |
Macros | |
| #define | PICSIM |
| #define | SERIAL_MAX 2 |
| #define | BUFFMAX 8192 |
| #define | PD_OUT 0x00 |
| #define | PD_IN 0x01 |
| #define | PT_POWER 0x00 |
| #define | PT_DIGITAL 0x01 |
| #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. | |
| #define | PMAX 35 |
| #define | init_pic(function, family, ID) |
Typedefs | |
| typedef struct _pic | _pic |
| PICsim PIC structure. | |
Functions | |
| int | pic_set_serial (_pic *pic_, int nser, const char *name, int flowcontrol, int ctspin, int rtspin) |
| Configure the serial port connection. | |
| int | pic_init (_pic *pic_, int processor, const char *fname, int leeprom, float freq) |
| Initialize one pic object. | |
| int | pic_reset (_pic *pic_, int flags) |
| Reset the microcontroller. | |
| void | pic_erase_flash (_pic *pic_) |
| erase the microcontroller FLASH | |
| void | pic_step (_pic *pic_) |
| Execute one simulation step. | |
| void | pic_end (_pic *pic_) |
| finalize and free pic object internal memory | |
| unsigned char | pic_get_pin (_pic *pic_, unsigned char pin) |
| Get digital value of one pin. | |
| int | pic_set_pin (_pic *pic_, unsigned char pin, unsigned char value) |
| Set digital value of one pin. | |
| int | pic_set_apin (_pic *pic_, unsigned char pin, float value) |
| Set digital value of one pin. | |
| unsigned char | pic_get_pin_type (_pic *pic_, unsigned char pin) |
| Get type of one pin. | |
| unsigned char | pic_get_pin_dir (_pic *pic_, unsigned char pin) |
| Get dir of one pin. | |
| unsigned char | pic_get_pin_DOV (_pic *pic_, unsigned char pin) |
| Get Default Open Value of one pin (external PULL UP) | |
| int | pic_set_pin_DOV (_pic *pic_, unsigned char pin, unsigned char value) |
| Set Default Open Value of one pin (external PULL UP) | |
| void | pic_icsp_init (_pic *pic_) |
| Initialize P16 ICSP support. | |
| int | pic_icsp (_pic *pic_) |
| Run P16 ICSP (must be pooling) | |
| void | pic_icsp_init18 (_pic *pic_) |
| Initialize P18 ICSP support. | |
| int | pic_icsp18 (_pic *pic_) |
| Run P18 ICSP (must be pooling) | |
| int | read_ihx (_pic *pic_, const char *fname, int leeprom) |
| Read HEX file to P16 microcontroller. | |
| int | read_ihx_16e (_pic *pic_, const char *fname, int leeprom) |
| Read HEX file to P16E microcontroller. | |
| int | read_ihx_18 (_pic *pic_, const char *fname, int leeprom) |
| Read HEX file to P18 microcontroller. | |
| int | write_ihx (_pic *pic_, const char *fname) |
| Dump all non volatile P16 microcontroller memory to HEX file. | |
| int | write_ihx16e (_pic *pic_, const char *fname) |
| Dump all non volatile P16E microcontroller memory to HEX file. | |
| int | write_ihx18 (_pic *pic_, const char *fname) |
| Dump all non volatile P18 microcontroller memory to HEX file. | |
| int | getproclist (char list[][30], int size) |
| Return list name of supported processors. | |
| unsigned int | getprocbyname (const char *str) |
| Return processor ID by name. | |
| unsigned int | getfprocbyname (const char *str) |
| Return processor family ID by name. | |
| unsigned int | getfprocbynumber (int proc) |
| Return processor family ID by ID. | |
| char * | getnamebyproc (int proc, char *str) |
| Return processor name by ID. | |
| const char * | getFSRname_16 (unsigned int addr) |
| Return P16 FSR name by address. | |
| const char * | getFSRname_16E (unsigned int addr) |
| Return P16E FSR name by address. | |
| const char * | getFSRname_16E2 (unsigned int addr) |
| Return P16E2 FSR name by address. | |
| const char * | getFSRname_18 (unsigned int addr) |
| Return P18 FSR name by address. | |
| const char * | getPinName (_pic *pic, int pin, char *pname) |
| Return pin name. | |
| void | pic_register (pic_desc picd) |
Variables | |
| unsigned char | NO_IO [6] |
| 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 | ( | _pic * | pic_, |
| unsigned char | pin | ||
| ) |
Get digital value of one pin.
| pin | pin number |
| unsigned char pic_get_pin_dir | ( | _pic * | pic_, |
| unsigned char | pin | ||
| ) |
| unsigned char pic_get_pin_DOV | ( | _pic * | pic_, |
| unsigned char | pin | ||
| ) |
Get Default Open Value of one pin (external PULL UP)
| pin | pin number |
| unsigned char pic_get_pin_type | ( | _pic * | pic_, |
| unsigned char | pin | ||
| ) |
| int pic_icsp | ( | _pic * | pic_ | ) |
Run P16 ICSP (must be pooling)
| int pic_icsp18 | ( | _pic * | pic_ | ) |
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 | ( | _pic * | pic_, |
| 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 | ( | _pic * | pic_, |
| 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 | ( | _pic * | pic_, |
| 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 | ( | _pic * | pic_, |
| 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 | ( | _pic * | pic_ | ) |
Execute one simulation step.
Execute one simulation step, must be call continuously to run the program in pic flash memory
| int read_ihx | ( | _pic * | pic_, |
| 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 | ( | _pic * | pic_, |
| 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 | ( | _pic * | pic_, |
| 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 | ( | _pic * | pic_, |
| const char * | fname | ||
| ) |
Dump all non volatile P16 microcontroller memory to HEX file.
| fname | name of .hex file |
| int write_ihx16e | ( | _pic * | pic_, |
| const char * | fname | ||
| ) |
Dump all non volatile P16E microcontroller memory to HEX file.
| fname | name of .hex file |
| int write_ihx18 | ( | _pic * | pic_, |
| const char * | fname | ||
| ) |
Dump all non volatile P18 microcontroller memory to HEX file.
| fname | name of .hex file |