PicGIM 0.5 documentation    
Copyright (C) 2002, 2013 - [AsYntote-SkyMatrix] gKript.org    
Generated on Sun Apr 26 2015 11:03:33 with DoxyGen 1.8.8    
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
The language of PicGIM


Language.png



PicGIM also introduces changes to the classic references of the Microchip environment.
These changes affect different components such as the types of variables and the PIN names.
These changes were made with the purpose to simplify the code writing.

Note
The types of variables and pin names proposed by PicGIM do not override standards introduced by the C18 compiler.

Variable Type name reference


The variable types have been reorganized to size and signed and unsigned.

Real size PicGIM type STD type Description
1 byte _pg_int8 charSigned integer 8 bit size
1 byte _pg_Uint8 unsigned charUnsigned integer 8 bit size
2 byte _pg_int16 intSigned integer 16 bit size
2 byte _pg_Uint16 unsigned intUnsigned integer 16 bit size
3 byte _pg_int24 short longSigned integer 24 bit size
3 byte _pg_Uint24 unsigned short longUnsigned integer 24 bit size
4 byte _pg_int32 longSigned integer 32 bit size
4 byte _pg_Uint32 unsigned longUnsigned integer 32 bit size
4 byte _pg_buffer char *A pointer to a signed integer 8 bit size
4 byte _pg_Ubuffer unsigned char *A pointer to a unsigned integer 8 bit size
4 byte _pg_bool BOOLA boolean flag

A practical code example.

...
void main( void ) {
_pg_int8 small_counter , reg_a = 0;
_pg_Uint32 big_counter;
_pg_Uint16 values[32];
_pg_bool test = false;
...


Pins name reference


In addition PicGIM reorganizes the names of pins to different contexts ( TRIS, PORT, LAT ).
Here is a reference table for each port.

Attention
The amount, the arrangement and the names of available pins is related to the model of microcontroller used.


Port A

PIN TRIS name PORT name ( for READ ) LAT name ( for WRITE )
  STDPicGIM STDPicGIM STDPicGIM
A0 TRISAbits.TRISA0T_A0 PORTAbits.RA0P_A0 LATAbits.LATA0L_A0
A1 TRISAbits.TRISA1T_A1 PORTAbits.RA1P_A1 LATAbits.LATA1L_A1
A2 TRISAbits.TRISA2T_A2 PORTAbits.RA2P_A2 LATAbits.LATA2L_A2
A3 TRISAbits.TRISA3T_A3 PORTAbits.RA3P_A3 LATAbits.LATA3L_A3
A4 TRISAbits.TRISA4T_A4 PORTAbits.RA4P_A4 LATAbits.LATA4L_A4
A5 TRISAbits.TRISA5T_A5 PORTAbits.RA5P_A5 LATAbits.LATA5L_A5
A6 TRISAbits.TRISA6T_A6 PORTAbits.RA6P_A6 LATAbits.LATA6L_A6
A7 TRISAbits.TRISA7T_A7 PORTAbits.RA7P_A7 LATAbits.LATA7L_A7

Port B

PIN TRIS name PORT name ( for READ ) LAT name ( for WRITE )
  STDPicGIM STDPicGIM STDPicGIM
B0 TRISBbits.TRISB0T_B0 PORTBbits.RB0P_B0 LATBbits.LATB0L_B0
B1 TRISBbits.TRISB1T_B1 PORTBbits.RB1P_B1 LATBbits.LATB1L_B1
B2 TRISBbits.TRISB2T_B2 PORTBbits.RB2P_B2 LATBbits.LATB2L_B2
B3 TRISBbits.TRISB3T_B3 PORTBbits.RB3P_B3 LATBbits.LATB3L_B3
B4 TRISBbits.TRISB4T_B4 PORTBbits.RB4P_B4 LATBbits.LATB4L_B4
B5 TRISBbits.TRISB5T_B5 PORTBbits.RB5P_B5 LATBbits.LATB5L_B5
B6 TRISBbits.TRISB6T_B6 PORTBbits.RB6P_B6 LATBbits.LATB6L_B6
B7 TRISBbits.TRISB7T_B7 PORTBbits.RB7P_B7 LATBbits.LATB7L_B7

Port C

PIN TRIS name PORT name ( for READ ) LAT name ( for WRITE )
  STDPicGIM STDPicGIM STDPicGIM
C0 TRISCbits.TRISC0T_C0 PORTCbits.RC0P_C0 LATCbits.LATC0L_C0
C1 TRISCbits.TRISC1T_C1 PORTCbits.RC1P_C1 LATCbits.LATC1L_C1
C2 TRISCbits.TRISC2T_C2 PORTCbits.RC2P_C2 LATCbits.LATC2L_C2
C3 TRISCbits.TRISC3T_C3 PORTCbits.RC3P_C3 LATCbits.LATC3L_C3
C4 TRISCbits.TRISC4T_C4 PORTCbits.RC4P_C4 LATCbits.LATC4L_C4
C5 TRISCbits.TRISC5T_C5 PORTCbits.RC5P_C5 LATCbits.LATC5L_C5
C6 TRISCbits.TRISC6T_C6 PORTCbits.RC6P_C6 LATCbits.LATC6L_C6
C7 TRISCbits.TRISC7T_C7 PORTCbits.RC7P_C7 LATCbits.LATC7L_C7

Port D

PIN TRIS name PORT name ( for READ ) LAT name ( for WRITE )
  STDPicGIM STDPicGIM STDPicGIM
D0 TRISDbits.TRISD0T_D0 PORTDbits.RD0P_D0 LATDbits.LATD0L_D0
D1 TRISDbits.TRISD1T_D1 PORTDbits.RD1P_D1 LATDbits.LATD1L_D1
D2 TRISDbits.TRISD2T_D2 PORTDbits.RD2P_D2 LATDbits.LATD2L_D2
D3 TRISDbits.TRISD3T_D3 PORTDbits.RD3P_D3 LATDbits.LATD3L_D3
D4 TRISDbits.TRISD4T_D4 PORTDbits.RD4P_D4 LATDbits.LATD4L_D4
D5 TRISDbits.TRISD5T_D5 PORTDbits.RD5P_D5 LATDbits.LATD5L_D5
D6 TRISDbits.TRISD6T_D6 PORTDbits.RD6P_D6 LATDbits.LATD6L_D6
D7 TRISDbits.TRISD7T_D7 PORTDbits.RD7P_D7 LATDbits.LATD7L_D7

Port E

PIN TRIS name PORT name ( for READ ) LAT name ( for WRITE )
  STDPicGIM STDPicGIM STDPicGIM
E0 TRISEbits.TRISE0T_E0 PORTEbits.RE0P_E0 LATEbits.LATE0L_E0
E1 TRISEbits.TRISE1T_E1 PORTEbits.RE1P_E1 LATEbits.LATE1L_E1
E2 TRISEbits.TRISE2T_E2 PORTEbits.RE2P_E2 LATEbits.LATE2L_E2
E3 TRISEbits.TRISE3T_E3 PORTEbits.RE3P_E3 LATEbits.LATE3L_E3
E4 TRISEbits.TRISE4T_E4 PORTEbits.RE4P_E4 LATEbits.LATE4L_E4
E5 TRISEbits.TRISE5T_E5 PORTEbits.RE5P_E5 LATEbits.LATE5L_E5
E6 TRISEbits.TRISE6T_E6 PORTEbits.RE6P_E6 LATEbits.LATE6L_E6
E7 TRISEbits.TRISE7T_E7 PORTEbits.RE7P_E7 LATEbits.LATE7L_E7

Port F

PIN TRIS name PORT name ( for READ ) LAT name ( for WRITE )
  STDPicGIM STDPicGIM STDPicGIM
F0 TRISFbits.TRISF0T_F0 PORTFbits.RF0P_F0 LATFbits.LATF0L_F0
F1 TRISFbits.TRISF1T_F1 PORTFbits.RF1P_F1 LATFbits.LATF1L_F1
F2 TRISFbits.TRISF2T_F2 PORTFbits.RF2P_F2 LATFbits.LATF2L_F2
F3 TRISFbits.TRISF3T_F3 PORTFbits.RF3P_F3 LATFbits.LATF3L_F3
F4 TRISFbits.TRISF4T_F4 PORTFbits.RF4P_F4 LATFbits.LATF4L_F4
F5 TRISFbits.TRISF5T_F5 PORTFbits.RF5P_F5 LATFbits.LATF5L_F5
F6 TRISFbits.TRISF6T_F6 PORTFbits.RF6P_F6 LATFbits.LATF6L_F6
F7 TRISFbits.TRISF7T_F7 PORTFbits.RF7P_F7 LATFbits.LATF7L_F7

Port G

PIN TRIS name PORT name ( for READ ) LAT name ( for WRITE )
  STDPicGIM STDPicGIM STDPicGIM
G0 TRISGbits.TRISG0T_G0 PORTGbits.RG0P_G0 LATGbits.LATG0L_G0
G1 TRISGbits.TRISG1T_G1 PORTGbits.RG1P_G1 LATGbits.LATG1L_G1
G2 TRISGbits.TRISG2T_G2 PORTGbits.RG2P_G2 LATGbits.LATG2L_G2
G3 TRISGbits.TRISG3T_G3 PORTGbits.RG3P_G3 LATGbits.LATG3L_G3
G4 TRISGbits.TRISG4T_G4 PORTGbits.RG4P_G4 LATGbits.LATG4L_G4
G5 TRISGbits.TRISG5T_G5 PORTGbits.RG5P_G5 LATGbits.LATG5L_G5
G6 TRISGbits.TRISG6T_G6 PORTGbits.RG6P_G6 LATGbits.LATG6L_G6
G7 TRISGbits.TRISG7T_G7 PORTGbits.RG7P_G7 LATGbits.LATG7L_G7

Port H

PIN TRIS name PORT name ( for READ ) LAT name ( for WRITE )
  STDPicGIM STDPicGIM STDPicGIM
H0 TRISHbits.TRISH0T_H0 PORTHbits.RH0P_H0 LATHbits.LATH0L_H0
H1 TRISHbits.TRISH1T_H1 PORTHbits.RH1P_H1 LATHbits.LATH1L_H1
H2 TRISHbits.TRISH2T_H2 PORTHbits.RH2P_H2 LATHbits.LATH2L_H2
H3 TRISHbits.TRISH3T_H3 PORTHbits.RH3P_H3 LATHbits.LATH3L_H3
H4 TRISHbits.TRISH4T_H4 PORTHbits.RH4P_H4 LATHbits.LATH4L_H4
H5 TRISHbits.TRISH5T_H5 PORTHbits.RH5P_H5 LATHbits.LATH5L_H5
H6 TRISHbits.TRISH6T_H6 PORTHbits.RH6P_H6 LATHbits.LATH6L_H6
H7 TRISHbits.TRISH7T_H7 PORTHbits.RH7P_H7 LATHbits.LATH7L_H7



The MACRO for handling PINS


This is a list of macros defined for handling PINs.


  • pg_pin_mode() : This macro is useful to set a specific bit as INPUT or OUTPUT.
  • pg_pin_set() : This macro is useful to set a specific bit to logic level ONE.
  • pg_pin_clear() : This macro is useful to set a specific bit to logic level ZERO.
  • pg_pin_write() : This macro is useful to set a specific bit to a specific value.
  • pg_pin_read() : This macro is useful to read the logical level of a specific bit.
  • pg_pin_toggle() : With this function you can reverse the logic value present. If the value is 1 after the call will be 0, and vice versa.

A code example

Here is a simple example of how to use the pin macro in your code.



The Mathematical,Phisical and Chemistry constants


PicGIM also contains defines mathematical, physical and chemical properties useful if necessary for possible formulas in the user application.

Type Name Description
Mathematical PG_CONSTANTS_PI Pi-Greek
Mathematical PG_CONSTANTS_EULER Euler's number. Base of the natural logarithm



Phisical PG_CONSTANTS_LIGHT_VELOCITY Speed of light. Unit of measure: [m/s]
Phisical PG_CONSTANTS_BOLTZMANN Boltzmann's constant. Unit of measure: [J/K]
Phisical PG_CONSTANTS_PLANK_JS Planck's constant. Unit of measure: [J*s]
Phisical PG_CONSTANTS_PLANK_EV Planck's constant. Unit of measure: [eV*s]
Phisical PG_CONSTANTS_ELEMENTARY_CHARGE Elementary charge. Unit of measure: [C]
Phisical PG_CONSTANTS_GRAVITY_ACCELERATION Gravitational acceleration. Unit of measure: [m/(s^2)]
Phisical PG_CONSTANTS_KELVIN_CONST Absolute value of the absolute zero temperature (0°K) in degrees Celsius



Chemistry PG_CONSTANTS_AVOGADRO Avogadro's number



The Defines of PicGIM.


PicGIM provides the programmer some defines that help to maintain the context of the code. There are three categories of defines: Loop, Tris, Logical and Time/Frequency. Here the reference table:

Type Name Description
Loop PG_LOOP( a ) A conditional Loop
Loop PG_INFINITE_LOOP A forever loop
Loop PG_HALT A forever loop
Loop pg_loop A forever loop
Loop PG_FOREVER An argument for PG_LOOP( a )



Tris PG_IN To program a PIN in INPUT
Tris PG_OUT To program a PIN in OUTPUT
Tris PG_8BIT_IN To program an entire PORT in INPUT
Tris PG_8BIT_OUT To program an entire PORT in OUTPUT



Logical PG_OK An alternative way to say "logic value 1"
Logical PG_NOK An alternative way to say "logic value 0"
Logical PG_DONE An alternative way to say "logic value 1"
Logical PG_NOT_DONE An alternative way to say "logic value 0"
Logical PG_YES An alternative way to say "logic value 1"
Logical PG_NO An alternative way to say "logic value 0"
Logical PG_ON An alternative way to say "logic value 1"
Logical PG_OFF An alternative way to say "logic value 0"
Logical PG_HIGH An alternative way to say "logic value 1"
Logical PG_LOW An alternative way to say "logic value 0"
Logical PG_TRISTATE Tristate when available
Logical PG_SET An alternative way to say "logic value 1"
Logical PG_CLEAR An alternative way to say "logic value 0"
Logical PG_START An alternative way to say "logic value 1"
Logical PG_STOP An alternative way to say "logic value 0"
Logical PG_ENABLE An alternative way to say "logic value 1"
Logical PG_DISABLE An alternative way to say "logic value 0"
Logical PG_NOT_INCLUDE An alternative way to say "logic value 0"
Logical PG_MASTER An alternative way to say "logic value 1"
Logical PG_SLAVE An alternative way to say "logic value 0"
Logical PG_BUSY An alternative way to say "logic value 1"
Logical PG_READY An alternative way to say "logic value 0"
Logical PG_TRUE An alternative way to say "logic value 1"
Logical PG_FALSE An alternative way to say "logic value 0"



Time/Frequency PG_SEC A time unit : Second
Time/Frequency PG_MSEC A time unit : Millisecond
Time/Frequency PG_USEC A time unit : Microsecond
Time/Frequency PG_HZ A frequency unit : Hertz
Time/Frequency PG_KHZ A frequency unit : Kilohertz
Time/Frequency PG_MHZ A frequency unit : Megahertz