Hardware/PICEBS3/Welcome

(Difference between revisions)
Jump to: navigation, search
(Software)
(Tips & tricks)
(34 intermediate revisions by one user not shown)
Line 9: Line 9:
 
The Mikroe board has been just modified for our laboratories usage.
 
The Mikroe board has been just modified for our laboratories usage.
  
Please note that, as a student, you can '''loan a board for free''' during your studies to work at home ;-) Just ask the laboratory responsible [[User:sap|Pascal Sartoretti]] (sap) for the procedure to follow.
+
Please note that, as a student, you can '''loan a board for free''' during your studies to work at home. Just ask the laboratory responsible [[User:sap|Pascal Sartoretti]] (sap) for the procedure to follow.
 
[[File:PICEBS3.jpg|400px|center]]
 
[[File:PICEBS3.jpg|400px|center]]
  
 
We, [[Hardware/PICEBS/2/Team |the PICEBS3 team]], provide a comprehensive solution for
 
We, [[Hardware/PICEBS/2/Team |the PICEBS3 team]], provide a comprehensive solution for
* Practical work for [http://hevs.ch HEI] course [http://sin.begincoding.net ''Information systems''] given in second year.
+
* Practical work for [http://hevs.ch HEI] course Information System given in second year.
 
* All kind of project featuring a small-sized micro-controller.
 
* All kind of project featuring a small-sized micro-controller.
  
Line 28: Line 28:
  
 
=== Hardware ===
 
=== Hardware ===
([[[http://wiki.hevs.ch/uit/index.php5/Hardware/PIcEBS Datasheets and schematics]]]).  
+
 
 +
{|class=wikitable
 +
|-
 +
! Photo || Schematic || Datasheets
 +
|-
 +
[[File:PICEBS3.jpg|200px]] [[File:picbox.jpg|200px|PICEBS 3 Box]]||
 +
[[Media:easypic-PRO-v8-schematic.pdf|PICEBS 3 - EasyPICPro v8 schematic]]
 +
 
 +
[[Media:Schematic-18F97J94.pdf|CPU board 18F97J94]]
 +
 
 +
[[Media:mcp2518fd-2-click-schematic-v100.pdf|Mikrobus CAN MCP2518FD]]
 +
 
 +
[[Media:tft-board-capacitive-5-schematic-v108.pdf|LCD capacitive 800x480]]
 +
 
 +
[[Media:lcd-2x16-datasheet.pdf|LCD 2x16 chars]]
 +
 
 +
||
 +
[[Media:18F97J94.pdf|CPU PIC18F97J94 datasheet]]
 +
 
 +
[[Media:SSD1963.pdf|LCD controller SSD1963 datasheet]]
 +
 
 +
[[Media:MCP2518FD.pdf|CAN FD controller MCP2518FD datasheet]]
 +
 
 +
 
 +
 
 +
|-
 +
|}
 +
 
  
 
Here is a list of the main PICEBS3's characteristics:
 
Here is a list of the main PICEBS3's characteristics:
Line 34: Line 61:
 
* CPU PIC18F97J94
 
* CPU PIC18F97J94
 
** High range PIC18 family with 128kB Flash & 4kB RAM, Lite PPS
 
** High range PIC18 family with 128kB Flash & 4kB RAM, Lite PPS
 +
** XLP technology (deep sleep @ 80nA)
 
** 12 bits ADC
 
** 12 bits ADC
 
** 9 timers
 
** 9 timers
 +
** RTC
 
** 4 UART, 2 SPI, 2 I2C
 
** 4 UART, 2 SPI, 2 I2C
** USB
+
** USB device (Low and Full Speed)
 
** ...
 
** ...
 
* Onboard SNAP debugger (not on EasyPicPro v8 standard)
 
* Onboard SNAP debugger (not on EasyPicPro v8 standard)
** Compatible with MPLABX (uage of USB-A cable is mandatory)
+
** Compatible with MPLABX IDE (usage of USB-A cable is mandatory)
 
* I/O ports
 
* I/O ports
 
** 10 ports with optional led
 
** 10 ports with optional led
 
** each of them with a button (pull-up or pull-down selectable)
 
** each of them with a button (pull-up or pull-down selectable)
** Capacitive multi points touch screen
+
* Displays (only one usable at the same time)
* LCD Display
+
** LCD Display
** 800x480
+
*** 800x480
** Backlight
+
*** Capacitive multi points touch screen
** Capacitive multi points touch screen
+
*** Backlight
 +
** 2x16 char display
 +
*** Backlight
 
* Networking and communication
 
* Networking and communication
 
** CAN bus
 
** CAN bus
 
** RS232 (throuth USB FTDI)
 
** RS232 (throuth USB FTDI)
** USB interface
+
** USB interface (device, low or full speed)
 
** Ethernet interface(not with the CPU module PIC18F97J94)
 
** Ethernet interface(not with the CPU module PIC18F97J94)
  
Line 60: Line 91:
  
 
=== Software ===
 
=== Software ===
To access these files on hevs gitlab, choose the user ''hevslabs'' with the password ''hevslabs'' !
+
Use MPLABX-IDE ([https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-x-ide download]) development system.
 +
 
 +
Use XC8 compiler ([https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-xc-compilers#tabs download]) for C programming.
 +
 
 +
----
 +
 
 +
To access these files on hevs gitlab, choose the user: ''"hevslabs"'' with the password: ''"hevslabs"'' (standard login, not LDAP)
 +
 
 
* Source files for assembler laboratories
 
* Source files for assembler laboratories
** [https://hevslabs:hevslabs@repos.hevs.ch/svn/picebs2-labs/trunk/conf_bits.inc Configuration bits for PICEBS3 in assembler]
+
** [https://hevslabs:hevslabs@gitlab.hevs.ch/course/picebs3/configuration-picebs3/blob/master/conf_bits.inc Configuration bits for PICEBS3 in assembler]
 
* Source files for C laboratories  
 
* Source files for C laboratories  
 
** [https://hevslabs:hevslabs@gitlab.hevs.ch/course/picebs3/configuration-picebs3/blob/master/conf_bits.c Configuration bits for PICEBS3 in C]
 
** [https://hevslabs:hevslabs@gitlab.hevs.ch/course/picebs3/configuration-picebs3/blob/master/conf_bits.c Configuration bits for PICEBS3 in C]
** [https://hevslabs:hevslabs@repos.hevs.ch/svn/picebs2-labs/trunk/can CAN libraries files]
+
** [https://hevslabs:hevslabs@gitlab.hevs.ch/course/picebs3/can-library CAN librarie files]
** [https://hevslabs:hevslabs@repos.hevs.ch/svn/picebs2-labs/trunk/lcd LCD libraries files]
+
** [https://hevslabs:hevslabs@gitlab.hevs.ch/course/picebs3/lcd-library LCD librarie files]
 
* Tools  
 
* Tools  
 
** [https://hevslabs:hevslabs@repos.hevs.ch/svn/picebs2-labs/trunk/incbin.exe incbin.exe -> Transform any file in a 'C' table of characters (for bitmaps, ...)]
 
** [https://hevslabs:hevslabs@repos.hevs.ch/svn/picebs2-labs/trunk/incbin.exe incbin.exe -> Transform any file in a 'C' table of characters (for bitmaps, ...)]
Line 75: Line 113:
 
<pre>
 
<pre>
 
// to work at maximum CPU speed (64MHz) insert following code at start.
 
// to work at maximum CPU speed (64MHz) insert following code at start.
   PLLEN = 1;            // activate PLL x4
+
   OSCCON3 = 0;            // for 64MHz cpu clock (default is 32MHz)
  OSCCON = 0b01110000;  // for 64MHz cpu clock (default is 8MHz)
+
// Caution -> the PLL needs up to 2 [ms] to start !
+
// Wait a moment if needed with: __delay_ms(2);
+
 
   ...
 
   ...
 +
</pre>
 +
* Assembler example
 +
<pre>
 +
#include <xc.inc> 
 +
#include "conf_bits.inc"
 +
PSECT main,class=CODE
 +
main:   
 +
movlw    0x00        ; move literal value 0x00 to W
 +
movwf    TRISH,a    ; move the content of W to TRISH, (access bank)
 +
movlb 0x01     ; select bank
 +
movwf    0x125,b    ; move W to memory position 0x125 (banked)
 +
goto $              ; stay here
 +
    end main
 +
</pre>
 +
* Configure PPS lite UART1 to FTDI PICEBS3 USB interface
 +
<pre>
 +
// code in C
 +
  RPOR18_19bits.RPO18R = 1; // map RC6 to RX FTDI (output of CPU) UART1_TX
 +
  RPINR0_1bits.U1RXR = 4;  // map RC7 to TX FTDI (input of CPU) UART1_RX
 +
 +
// code in assembler (movff because banked)
 +
  MOVLW  0x01
 +
  MOVFF  WREG,RPOR18_19    ; map RC6 to UART1_TX
 +
  MOVLW  0x04
 +
  MOVFF  WREG,RPINR0_1      ; map RC7 to UART1_RX
 +
 
</pre>
 
</pre>
 
* Change one bit on a port
 
* Change one bit on a port
Line 87: Line 148:
 
   ...
 
   ...
 
</pre>
 
</pre>
* Interrupt on change on PORTB (RB4-RB7)
+
* Interrupt implementation with XC8 compiler (below 2.0) and (2.0 or above)
 
<pre>
 
<pre>
// to clear the interrupt flag you have to read the PORTB
+
// below 2.0 implementation
  ...
+
void interrupt AnyISR(void)
  PORTB;              // clear the latch change on PORTB
+
{
  RBIF = 0;            // clear the interrupt itself
+
  if(INT0IF == 1)
  ...
+
  {
</pre>
+
    ...
* Reduce current consumption
+
  }
<pre>
+
}
// To reduce consumption at minimum, do at least
+
// 2.0 or above implementation
  LCD_PowerOff();  // turn all LCD parts off
+
void __interrupt(high_priority) AnyISR(void)
  UART_PowerOff(); // turn UART driver off
+
{
  Can_PowerOff();  // turn off MCP2515 chipset
+
  if(INT0IF == 1)
// And define unused GPIOs as output
+
  {
  TRISB5 = 0;      // for example
+
    ...
  ...
+
  }
// You can measure (between white and yellow test points) about 630 uA after a SLEEP();
+
}
 
</pre>
 
</pre>
* Link in low address range (download time reduced)
+
* Remove warning conversion in compiler 2.0 or above
 
<pre>
 
<pre>
  - To reduce the time to download, you need to write a linker special command
+
In the XC8 Compiler "Additional options", insert the line below
      In the "XC8 linker" - "Extra Linker Option" write the following line:
+
-Xparser -Wno-conversion
      "-L-ACODE=0x0-0x10000 -L-AMEDIUMCONST=0x0-0x10000"
+
  - Another solution is to have an interrupt routine (even if nothing in)
+
  The full program needs to be smaller than 50% of CPU Flash memory.
+
 
</pre>
 
</pre>
  
 
== Bugs, issues, questions and comments ==
 
== Bugs, issues, questions and comments ==
Feel free to contact the [[Hardware/PICEBS/2/Team |PICEBS2 team]] if you encounter a problem. Do not forget to have a look at the [[#Tips & tricks| Tips & tricks]] section.
+
Feel free to contact the [[Hardware/PICEBS/2/Team |PICEBS3 team]] if you encounter a problem. Do not forget to have a look at the [[#Tips & tricks| Tips & tricks]] section.

Revision as of 07:57, 30 August 2021

Contents

Welcome to the PICEBS3 wiki

PICEBS3 is the name of a small embedded computer board targeted at teaching embedded systems programming based on the Mikroe EasyPicPro v8 board. As its name suggests, it is the third iteration of a successful family of Microchip PIC board.

The Mikroe board has been just modified for our laboratories usage.

Please note that, as a student, you can loan a board for free during your studies to work at home. Just ask the laboratory responsible Pascal Sartoretti (sap) for the procedure to follow.

PICEBS3.jpg

We, the PICEBS3 team, provide a comprehensive solution for

  • Practical work for HEI course Information System given in second year.
  • All kind of project featuring a small-sized micro-controller.


What can be done with the PICEBS3?

The board is powerful enough to run applications with:

  • LCD and touch screen interface
  • Serial port usage (UART)
  • CAN interface
  • ...

To program this board, you do not require an external programming probe, as it already includes a "Microchip Snap"system for programming and debugging. All you need is an USB port and the free MPLAB-X IDE. Caution, the USB câble has to be an USB-A cable.

Hardware

Photo Schematic Datasheets
PICEBS3.jpg PICEBS 3 Box

PICEBS 3 - EasyPICPro v8 schematic

CPU board 18F97J94

Mikrobus CAN MCP2518FD

LCD capacitive 800x480

LCD 2x16 chars

CPU PIC18F97J94 datasheet 
LCD controller SSD1963 datasheet 
CAN FD controller MCP2518FD datasheet 



Here is a list of the main PICEBS3's characteristics:

  • CPU PIC18F97J94
    • High range PIC18 family with 128kB Flash & 4kB RAM, Lite PPS
    • XLP technology (deep sleep @ 80nA)
    • 12 bits ADC
    • 9 timers
    • RTC
    • 4 UART, 2 SPI, 2 I2C
    • USB device (Low and Full Speed)
    • ...
  • Onboard SNAP debugger (not on EasyPicPro v8 standard)
    • Compatible with MPLABX IDE (usage of USB-A cable is mandatory)
  • I/O ports
    • 10 ports with optional led
    • each of them with a button (pull-up or pull-down selectable)
  • Displays (only one usable at the same time)
    • LCD Display
      • 800x480
      • Capacitive multi points touch screen
      • Backlight
    • 2x16 char display
      • Backlight
  • Networking and communication
    • CAN bus
    • RS232 (throuth USB FTDI)
    • USB interface (device, low or full speed)
    • Ethernet interface(not with the CPU module PIC18F97J94)
  • Development
    • Almost all CPU pins are available on connectors
    • CPU current measure available on a 1 ohm resistor (not on EasyPicPro v8 standard)

Software

Use MPLABX-IDE (download) development system.

Use XC8 compiler (download) for C programming.


To access these files on hevs gitlab, choose the user: "hevslabs" with the password: "hevslabs" (standard login, not LDAP)

Tips & tricks

  • CPU speed control
// to work at maximum CPU speed (64MHz) insert following code at start.
   OSCCON3 = 0;            // for 64MHz cpu clock (default is 32MHz)
   ...
  • Assembler example
#include <xc.inc>  
#include "conf_bits.inc"
PSECT main,class=CODE
main:    
 	movlw    0x00        ; move literal value 0x00 to W
 	movwf    TRISH,a     ; move the content of W to TRISH, (access bank)
	movlb	 0x01	     ; select bank
 	movwf    0x125,b     ; move W to memory position 0x125 (banked) 
 	goto $               ; stay here
    end main
  • Configure PPS lite UART1 to FTDI PICEBS3 USB interface
// code in C
  RPOR18_19bits.RPO18R = 1; // map RC6 to RX FTDI (output of CPU) UART1_TX
  RPINR0_1bits.U1RXR = 4;   // map RC7 to TX FTDI (input of CPU) UART1_RX

// code in assembler (movff because banked)
  MOVLW  0x01
  MOVFF  WREG,RPOR18_19     ; map RC6 to UART1_TX
  MOVLW  0x04
  MOVFF  WREG,RPINR0_1      ; map RC7 to UART1_RX

  • Change one bit on a port
// to change one bit on a port, use LATx and not PORTx
   LATH2 = 1;            // turn led on for example
   ...
  • Interrupt implementation with XC8 compiler (below 2.0) and (2.0 or above)
// below 2.0 implementation
void interrupt AnyISR(void)
{
  if(INT0IF == 1)
  {
    ...
  }
}
// 2.0 or above implementation
void __interrupt(high_priority) AnyISR(void)
{
  if(INT0IF == 1)
  {
    ...
  }
}
  • Remove warning conversion in compiler 2.0 or above
In the XC8 Compiler "Additional options", insert the line below
-Xparser -Wno-conversion

Bugs, issues, questions and comments

Feel free to contact the PICEBS3 team if you encounter a problem. Do not forget to have a look at the Tips & tricks section.

Personal tools
Namespaces
Variants
Actions
Navigation
Browse
Toolbox