From 2fcfcb12cdf218095779ffcd3dabc54498dad079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Tue, 22 Aug 2023 09:22:00 +0200 Subject: [PATCH] Initial commit --- 306-controller_interface.X/.gitignore | 29 + 306-controller_interface.X/Makefile | 113 + 306-controller_interface.X/app/blcontrol.c | 25 + 306-controller_interface.X/app/blcontrol.h | 19 + .../board/button/button.c | 66 + .../board/button/button.h | 25 + .../board/button/buttonsm.c | 129 + .../board/button/buttonsm.h | 69 + 306-controller_interface.X/board/led/led.c | 103 + 306-controller_interface.X/board/led/led.h | 23 + 306-controller_interface.X/factory/factory.c | 53 + 306-controller_interface.X/factory/factory.h | 41 + 306-controller_interface.X/main.c | 39 + .../mcc_generated_files/device_config.c | 97 + .../mcc_generated_files/device_config.h | 55 + .../mcc_generated_files/ecan.c | 754 + .../mcc_generated_files/ecan.h | 589 + .../mcc_generated_files/interrupt_manager.c | 80 + .../mcc_generated_files/interrupt_manager.h | 92 + .../mcc_generated_files/mcc.c | 97 + .../mcc_generated_files/mcc.h | 105 + .../mcc_generated_files/memory.c | 206 + .../mcc_generated_files/memory.h | 289 + .../mcc_generated_files/pin_manager.c | 124 + .../mcc_generated_files/pin_manager.h | 149 + .../mcc_generated_files/tmr0.c | 145 + .../mcc_generated_files/tmr0.h | 357 + .../nbproject/configurations.xml | 248 + .../nbproject/project.xml | 34 + 306-controller_interface.X/ss22ep.mc3 | 17228 ++++++++++++++++ 306-controller_interface.X/xf/event.c | 61 + 306-controller_interface.X/xf/event.h | 35 + 306-controller_interface.X/xf/ireactive.h | 8 + 306-controller_interface.X/xf/xf.c | 292 + 306-controller_interface.X/xf/xf.h | 84 + 35 files changed, 21863 insertions(+) create mode 100644 306-controller_interface.X/.gitignore create mode 100644 306-controller_interface.X/Makefile create mode 100644 306-controller_interface.X/app/blcontrol.c create mode 100644 306-controller_interface.X/app/blcontrol.h create mode 100644 306-controller_interface.X/board/button/button.c create mode 100644 306-controller_interface.X/board/button/button.h create mode 100644 306-controller_interface.X/board/button/buttonsm.c create mode 100644 306-controller_interface.X/board/button/buttonsm.h create mode 100644 306-controller_interface.X/board/led/led.c create mode 100644 306-controller_interface.X/board/led/led.h create mode 100644 306-controller_interface.X/factory/factory.c create mode 100644 306-controller_interface.X/factory/factory.h create mode 100644 306-controller_interface.X/main.c create mode 100644 306-controller_interface.X/mcc_generated_files/device_config.c create mode 100644 306-controller_interface.X/mcc_generated_files/device_config.h create mode 100644 306-controller_interface.X/mcc_generated_files/ecan.c create mode 100644 306-controller_interface.X/mcc_generated_files/ecan.h create mode 100644 306-controller_interface.X/mcc_generated_files/interrupt_manager.c create mode 100644 306-controller_interface.X/mcc_generated_files/interrupt_manager.h create mode 100644 306-controller_interface.X/mcc_generated_files/mcc.c create mode 100644 306-controller_interface.X/mcc_generated_files/mcc.h create mode 100644 306-controller_interface.X/mcc_generated_files/memory.c create mode 100644 306-controller_interface.X/mcc_generated_files/memory.h create mode 100644 306-controller_interface.X/mcc_generated_files/pin_manager.c create mode 100644 306-controller_interface.X/mcc_generated_files/pin_manager.h create mode 100644 306-controller_interface.X/mcc_generated_files/tmr0.c create mode 100644 306-controller_interface.X/mcc_generated_files/tmr0.h create mode 100644 306-controller_interface.X/nbproject/configurations.xml create mode 100644 306-controller_interface.X/nbproject/project.xml create mode 100644 306-controller_interface.X/ss22ep.mc3 create mode 100644 306-controller_interface.X/xf/event.c create mode 100644 306-controller_interface.X/xf/event.h create mode 100644 306-controller_interface.X/xf/ireactive.h create mode 100644 306-controller_interface.X/xf/xf.c create mode 100644 306-controller_interface.X/xf/xf.h diff --git a/306-controller_interface.X/.gitignore b/306-controller_interface.X/.gitignore new file mode 100644 index 0000000..f24b170 --- /dev/null +++ b/306-controller_interface.X/.gitignore @@ -0,0 +1,29 @@ +# .gitignore file + +# MPLAB X IDE (Netbeans) specific +~*.* +build/ +debug/ +dist/ +disassembly/ +nbproject/private/ +nbproject/*.mk +nbproject/*.bash +nbproject/Makefile-genesis.properties + +# Object files +*.o +*.ko +*.obj +*.elf + +# Executables +*.exe + + +# KDE specific +.directory + +# Misc +.svn +*.bak \ No newline at end of file diff --git a/306-controller_interface.X/Makefile b/306-controller_interface.X/Makefile new file mode 100644 index 0000000..fca8e2c --- /dev/null +++ b/306-controller_interface.X/Makefile @@ -0,0 +1,113 @@ +# +# There exist several targets which are by default empty and which can be +# used for execution of your targets. These targets are usually executed +# before and after some main targets. They are: +# +# .build-pre: called before 'build' target +# .build-post: called after 'build' target +# .clean-pre: called before 'clean' target +# .clean-post: called after 'clean' target +# .clobber-pre: called before 'clobber' target +# .clobber-post: called after 'clobber' target +# .all-pre: called before 'all' target +# .all-post: called after 'all' target +# .help-pre: called before 'help' target +# .help-post: called after 'help' target +# +# Targets beginning with '.' are not intended to be called on their own. +# +# Main targets can be executed directly, and they are: +# +# build build a specific configuration +# clean remove built files from a configuration +# clobber remove all built files +# all build all configurations +# help print help mesage +# +# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and +# .help-impl are implemented in nbproject/makefile-impl.mk. +# +# Available make variables: +# +# CND_BASEDIR base directory for relative paths +# CND_DISTDIR default top distribution directory (build artifacts) +# CND_BUILDDIR default top build directory (object files, ...) +# CONF name of current configuration +# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) +# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) +# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) +# CND_PACKAGE_DIR_${CONF} directory of package (current configuration) +# CND_PACKAGE_NAME_${CONF} name of package (current configuration) +# CND_PACKAGE_PATH_${CONF} path to package (current configuration) +# +# NOCDDL + + +# Environment +MKDIR=mkdir +CP=cp +CCADMIN=CCadmin +RANLIB=ranlib + + +# build +build: .build-post + +.build-pre: +# Add your pre 'build' code here... + +.build-post: .build-impl +# Add your post 'build' code here... + + +# clean +clean: .clean-post + +.clean-pre: +# Add your pre 'clean' code here... +# WARNING: the IDE does not call this target since it takes a long time to +# simply run make. Instead, the IDE removes the configuration directories +# under build and dist directly without calling make. +# This target is left here so people can do a clean when running a clean +# outside the IDE. + +.clean-post: .clean-impl +# Add your post 'clean' code here... + + +# clobber +clobber: .clobber-post + +.clobber-pre: +# Add your pre 'clobber' code here... + +.clobber-post: .clobber-impl +# Add your post 'clobber' code here... + + +# all +all: .all-post + +.all-pre: +# Add your pre 'all' code here... + +.all-post: .all-impl +# Add your post 'all' code here... + + +# help +help: .help-post + +.help-pre: +# Add your pre 'help' code here... + +.help-post: .help-impl +# Add your post 'help' code here... + + + +# include project implementation makefile +include nbproject/Makefile-impl.mk + +# include project make variables +include nbproject/Makefile-variables.mk diff --git a/306-controller_interface.X/app/blcontrol.c b/306-controller_interface.X/app/blcontrol.c new file mode 100644 index 0000000..60efb4f --- /dev/null +++ b/306-controller_interface.X/app/blcontrol.c @@ -0,0 +1,25 @@ +#include "blcontrol.h" +#include "../mcc_generated_files/mcc.h" +#include "../factory/factory.h" +//private methods + +void BLControl_init(BLControl* me) +{ + //nothing to do yet +} + +void BLControl_onButton(void * me, uint8_t buttonId, bool pressed) +{ + BLControl* realMe = (BLControl*)me; + if (buttonId == BID) + { + if (pressed) + { + LED_on(l()); + } + else + { + LED_off(l()); + } + } +} diff --git a/306-controller_interface.X/app/blcontrol.h b/306-controller_interface.X/app/blcontrol.h new file mode 100644 index 0000000..6b0e053 --- /dev/null +++ b/306-controller_interface.X/app/blcontrol.h @@ -0,0 +1,19 @@ +#ifndef BLCONTROL_DEF +#define BLCONTROL_DEF + +#include +#include +#include "../xf/xf.h" +#include "../board/button/buttonsm.h" + +struct BLControl_ +{ + +}; + +typedef struct BLControl_ BLControl; + +void BLControl_init(BLControl* me); +void BLControl_onButton(void* me, uint8_t buttonId, bool pressed); + +#endif diff --git a/306-controller_interface.X/board/button/button.c b/306-controller_interface.X/board/button/button.c new file mode 100644 index 0000000..158cf00 --- /dev/null +++ b/306-controller_interface.X/board/button/button.c @@ -0,0 +1,66 @@ + +#include "button.h" +#include "../../mcc_generated_files/pin_manager.h" + +void Button_init(Button* me, uint8_t id, bool isPullUp) +{ + me->id = id; + me->isPullUp = isPullUp; +} + +/** + * @brief Initialize the Driver + * + */ +void Button_initHW(Button* me) +{ +} + +//read the state of the button +//maybe you have to adjust the +//low level calls +uint8_t Button_read(Button* me) +{ + uint8_t value = LOW; + switch (me->id) + { + case 1: + value = IO_RA7_GetValue(); + break; + case 2: + break; + case 3: + break; + case 4: + break; + case 5: + break; + case 6: + break; + case 7: + break; + case 8: + break; + case 9: + break; + case 10: + break; + } + if (me->isPullUp == true) + { + value=value==LOW?HIGH:LOW; + } + return value; + } + +//id getter +uint8_t Button_getId(Button* me) +{ + return me->id; +} + +//id setter +void Button_setId(Button* me, uint8_t id) +{ + me->id = id; +} \ No newline at end of file diff --git a/306-controller_interface.X/board/button/button.h b/306-controller_interface.X/board/button/button.h new file mode 100644 index 0000000..de76a35 --- /dev/null +++ b/306-controller_interface.X/board/button/button.h @@ -0,0 +1,25 @@ +#ifndef Button_ONCE +#define Button_ONCE + +#include +#include + +/* + * this is the declaration of the Button class + */ + +struct Button_ +{ + uint8_t id; + bool isPullUp; +}; + +typedef struct Button_ Button; + +void Button_init(Button* me, uint8_t id, bool isPullUp); +void Button_initHW(Button* me); +uint8_t Button_read(Button* me); +void Button_setId(Button* me, uint8_t id); +uint8_t Button_getId(Button* me); + +#endif diff --git a/306-controller_interface.X/board/button/buttonsm.c b/306-controller_interface.X/board/button/buttonsm.c new file mode 100644 index 0000000..05e7fb9 --- /dev/null +++ b/306-controller_interface.X/board/button/buttonsm.c @@ -0,0 +1,129 @@ +#include "buttonsm.h" + +/* + * this is the init method of the ButtonSM class + */ +void ButtonSM_init(ButtonSM* me, Button* button) +{ + me->state = ST_BSMINIT; + me->button = button; + + me->actualState = ST_BSMINIT; + me->observer = NULL; + me->observerCB = NULL; +} + +/* + * this is the state machine method of the ButtonSM class + */ +bool ButtonSM_processEvent(Event* ev) +{ + ButtonSM* me = (ButtonSM*)ev->target; + bool processed = false; + BSMState oldState = me->state; + + switch (me->state) + { + case ST_BSMINIT: + if (Event_getId(ev) == evBSMInit) + { + me->state = ST_BSMWAIT; + } + break; + case ST_BSMWAIT: + if (Event_getId(ev) == evBSMPollTM) + { + me->state = ST_BSMPOLL; + } + break; + case ST_BSMPOLL: + if (Event_getId(ev) == evBSMDefault) + { + if (Button_read(me->button)==HIGH) + { + me->state = ST_BSMPRESSED; + } + else + { + me->state = ST_BSMRELEASED; + } + } + break; + case ST_BSMPRESSED: + if (Event_getId(ev) == evBSMDefault) + { + me->state = ST_BSMWAIT; + } + break; + case ST_BSMRELEASED: + if (Event_getId(ev) == evBSMDefault) + { + me->state = ST_BSMWAIT; + } + break; + } + if (oldState != me->state) + { + processed = true; + switch (me->state) + { + case ST_BSMINIT: + break; + case ST_BSMWAIT: + POST(me, &ButtonSM_processEvent, evBSMPollTM,POLLTM,0); + break; + case ST_BSMPOLL: + POST(me, &ButtonSM_processEvent, evBSMDefault,0,0); + break; + case ST_BSMPRESSED: + POST(me, &ButtonSM_processEvent, evBSMDefault,0,0); + if (me->actualState != ST_BSMPRESSED) + { + if (me->observerCB != NULL) + { + me->observerCB(me->observer,Button_getId(me->button),true); + me->actualState = ST_BSMPRESSED; + } + } + break; + case ST_BSMRELEASED: + POST(me, &ButtonSM_processEvent, evBSMDefault,0,0); + if (me->actualState != ST_BSMRELEASED) + { + if (me->observerCB != NULL) + { + me->observerCB(me->observer,Button_getId(me->button),false); + me->actualState = ST_BSMRELEASED; + } + } + break; + } + } + return processed; +} + +/* + * this is the start method for the + * state machine of the ButtonSM class + */ +void ButtonSM_startBehaviour(ButtonSM* me) +{ + POST(me, &ButtonSM_processEvent, evBSMInit,0,0); + me->actualState = Button_read(me->button)==HIGH?ST_BSMPRESSED:ST_BSMRELEASED; +} + +/* + * this is the method to set the object and the + * call back method of the ButtonSM class + * this method will be called whenever the + * button changes its state + * as parameters to the callback method will be passed + * the object address, the button id and its state + * if the call back method does not belong to a class, + * then the object address must be set to NULL + */ +void ButtonSM_setObserver(ButtonSM* me, void* observer, buttonObserverCBT observerCB) +{ + me->observer = observer; + me->observerCB = observerCB; +} \ No newline at end of file diff --git a/306-controller_interface.X/board/button/buttonsm.h b/306-controller_interface.X/board/button/buttonsm.h new file mode 100644 index 0000000..9353774 --- /dev/null +++ b/306-controller_interface.X/board/button/buttonsm.h @@ -0,0 +1,69 @@ +#ifndef BUTTONSM_DEF +#define BUTTONSM_DEF + +#include +#include +#include "../../xf/xf.h" +#include "button.h" + +/* + * these are the events of the + * button state machine + * be sure to make the first event + * in the enumeration different from 0 + */ +typedef enum BSMEvent +{ + evBSMInit = 10, + evBSMDefault, + evBSMPollTM +} BSMEvent; + +/* + * these are the states of the + * button state machine + */ +typedef enum BSMSTate_ +{ + ST_BSMINIT, + ST_BSMWAIT, + ST_BSMPOLL, + ST_BSMPRESSED, + ST_BSMRELEASED +} BSMState; + +/* + * the associated button will be polled + * each 50 ms. do not make this time + * shorter than TICKINTERVAL + */ +#define POLLTM 50 + +/* + * this is the prototype type of the callback function + * that will be called when the associated button + * changes from released to pressed or inverse. + */ +typedef void (*buttonObserverCBT)(void*, uint8_t, bool); + +/* + * this is the declaration of the ButtonSM class + */ +struct ButtonSM_ +{ + BSMState state; + Button* button; + BSMState actualState; + + buttonObserverCBT observerCB; + void* observer; +}; + +typedef struct ButtonSM_ ButtonSM; + + +void ButtonSM_init(ButtonSM* me, Button* button); +void ButtonSM_startBehaviour(ButtonSM* me); +bool ButtonSM_processEvent(Event* ev); +void ButtonSM_setObserver(ButtonSM* me, void* observer, buttonObserverCBT observerCB); +#endif diff --git a/306-controller_interface.X/board/led/led.c b/306-controller_interface.X/board/led/led.c new file mode 100644 index 0000000..cc4a4ba --- /dev/null +++ b/306-controller_interface.X/board/led/led.c @@ -0,0 +1,103 @@ +#include "led.h" +#include "../../mcc_generated_files/pin_manager.h" + +void LED_init(LED* me, uint8_t id) +{ + me->id = id; +} + +/** + * @brief Initialize the Driver + * + */ +void LED_initHW(LED* me) +{ + LED_off(me); +} + +/* + * for the on and the off methods: + * if the output is push pull, it depends if the + * load is connect to ground or vcc. + * in this case, the load is connected to vcc, + * so on and off are inverted. Change the code as it + * is convenient for your hardware + */ + + +//switch on the led +//maybe you have to adjust your +//low level calls +void LED_on(LED* me) +{ + switch (me->id) + { + case 1: + IO_RB0_SetLow(); + break; + case 2: + break; + case 3: + break; + case 4: + break; + case 5: + break; + case 6: + break; + case 7: + break; + case 8: + break; + case 9: + break; + case 10: + break; + } + +} + +//switch off the led +//maybe you have to adjust your +//low level calls +void LED_off(LED* me) +{ + switch (me->id) + { + case 1: + IO_RB0_SetHigh(); + break; + case 2: + break; + case 3: + break; + case 4: + break; + case 5: + break; + case 6: + break; + case 7: + break; + case 8: + break; + case 9: + break; + case 10: + break; + } + +} + +void LED_setState(LED* me, uint8_t state) +{ + if (state == HIGH) + { + LED_on(me); + } + + if (state == LOW) + { + LED_off(me); + } +} \ No newline at end of file diff --git a/306-controller_interface.X/board/led/led.h b/306-controller_interface.X/board/led/led.h new file mode 100644 index 0000000..1bc5873 --- /dev/null +++ b/306-controller_interface.X/board/led/led.h @@ -0,0 +1,23 @@ +#ifndef LED_ONCE +#define LED_ONCE + +#include + +/* + * this is the declaration of the Led class + */ +struct LED_ +{ + //has a gpo + uint8_t id; +}; + +typedef struct LED_ LED; + +void LED_init(LED* me, uint8_t id); +void LED_initHW(LED* me); +void LED_on(LED* me); +void LED_off(LED* me); +void LED_setState(LED* me,uint8_t state); + +#endif diff --git a/306-controller_interface.X/factory/factory.c b/306-controller_interface.X/factory/factory.c new file mode 100644 index 0000000..600f8bb --- /dev/null +++ b/306-controller_interface.X/factory/factory.c @@ -0,0 +1,53 @@ +#include "factory.h" + + +//the factory object containing all objects of our system +static Factory theFactory; + + +//all the getters +LED* l() +{ + return &theFactory.l_; +} + +Button* b() +{ + return &theFactory.b_; +} + +ButtonSM* bsm() +{ + return &theFactory.bsm_; +} + +BLControl* blc() +{ + return &theFactory.blc_; +} + + +//initialize all objects +void Factory_init() +{ + LED_init(l(),LID); + LED_initHW(l()); + Button_init(b(),BID, true); + Button_initHW(b()); + ButtonSM_init(bsm(),b()); + BLControl_init(blc()); +; + +} + +//connect objects if required +void Factory_build() +{ + ButtonSM_setObserver(bsm(), blc(), &BLControl_onButton); +} + +//start all state machines +void Factory_start() +{ + ButtonSM_startBehaviour(bsm()); +} diff --git a/306-controller_interface.X/factory/factory.h b/306-controller_interface.X/factory/factory.h new file mode 100644 index 0000000..4d630a9 --- /dev/null +++ b/306-controller_interface.X/factory/factory.h @@ -0,0 +1,41 @@ +/* this is the Factory class */ + + +#ifndef FACTORY_ONCE +#define FACTORY_ONCE + +#include +#include + +#include "../board/led/led.h" +#include "../board/button/button.h" +#include "../board/button/buttonsm.h" +#include "../app/blcontrol.h" + + +#define BID 1 +#define LID 1 + +void bObs(void*, uint8_t,bool); + +struct Factory_ +{ + LED l_; + Button b_; + ButtonSM bsm_; + BLControl blc_; +}; + +typedef struct Factory_ Factory; + +void Factory_init(); +void Factory_build(); +void Factory_start(); + +//these are global getters for our objects +LED* l(); +Button* b(); +ButtonSM* bsm(); +BLControl* blc(); + +#endif \ No newline at end of file diff --git a/306-controller_interface.X/main.c b/306-controller_interface.X/main.c new file mode 100644 index 0000000..1c5d0ae --- /dev/null +++ b/306-controller_interface.X/main.c @@ -0,0 +1,39 @@ +#include "mcc_generated_files/mcc.h" +#include "xf/xf.h" +#include "factory/factory.h" + +/* + * the main function + */ +void main(void) +{ + // Initialize the device + SYSTEM_Initialize(); + + // Enable the Global Interrupts + INTERRUPT_GlobalInterruptEnable(); + + // Disable the Global Interrupts + // INTERRUPT_GlobalInterruptDisable(); + + // initialize the XF + XF_init(); + + // produce the system + Factory_init(); + Factory_build(); + Factory_start(); + + // let the XF timers handling become the TMR0 interrupt handler + // this means that the XF timers are always decremented when the + // TMR0 is interrupting. Important: Set the TICKINTERVAL define in + //the xf.h file to the same value as the TMR0 value. + TMR0_SetInterruptHandler(XF_decrementAndQueueTimers); + + while (1) + { + //handle the next event if there is any in the queue + XF_executeOnce(); + //maybe sleep a short while to save energy + } +} \ No newline at end of file diff --git a/306-controller_interface.X/mcc_generated_files/device_config.c b/306-controller_interface.X/mcc_generated_files/device_config.c new file mode 100644 index 0000000..1e3bf51 --- /dev/null +++ b/306-controller_interface.X/mcc_generated_files/device_config.c @@ -0,0 +1,97 @@ +/** + @Generated PIC10 / PIC12 / PIC16 / PIC18 MCUs Source File + + @Company: + Microchip Technology Inc. + + @File Name: + mcc.c + + @Summary: + This is the device_config.c file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs + + @Description: + This header file provides implementations for driver APIs for all modules selected in the GUI. + Generation Information : + Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 + Device : PIC18F26K83 + Driver Version : 2.00 + The generated drivers are tested against the following: + Compiler : XC8 2.36 and above or later + MPLAB : MPLAB X 6.00 +*/ + +/* + (c) 2018 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip software and any + derivatives exclusively with Microchip products. It is your responsibility to comply with third party + license terms applicable to your use of third party software (including open source software) that + may accompany Microchip software. + + THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS + FOR A PARTICULAR PURPOSE. + + IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND + WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP + HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO + THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL + CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT + OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS + SOFTWARE. +*/ + +// Configuration bits: selected in the GUI + +// CONFIG1L +#pragma config FEXTOSC = OFF // External Oscillator Selection->Oscillator not enabled +#pragma config RSTOSC = HFINTOSC_64MHZ // Reset Oscillator Selection->HFINTOSC with HFFRQ = 64 MHz and CDIV = 1:1 + +// CONFIG1H +#pragma config CLKOUTEN = OFF // Clock out Enable bit->CLKOUT function is disabled +#pragma config PR1WAY = ON // PRLOCKED One-Way Set Enable bit->PRLOCK bit can be cleared and set only once +#pragma config CSWEN = ON // Clock Switch Enable bit->Writing to NOSC and NDIV is allowed +#pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable bit->Fail-Safe Clock Monitor enabled + +// CONFIG2L +#pragma config MCLRE = EXTMCLR // MCLR Enable bit->If LVP = 0, MCLR pin is MCLR; If LVP = 1, RE3 pin function is MCLR +#pragma config PWRTS = PWRT_OFF // Power-up timer selection bits->PWRT is disabled +#pragma config MVECEN = OFF // Multi-vector enable bit->Interrupt contoller does not use vector table to prioritze interrupts +#pragma config IVT1WAY = ON // IVTLOCK bit One-way set enable bit->IVTLOCK bit can be cleared and set only once +#pragma config LPBOREN = OFF // Low Power BOR Enable bit->ULPBOR disabled +#pragma config BOREN = SBORDIS // Brown-out Reset Enable bits->Brown-out Reset enabled , SBOREN bit is ignored + +// CONFIG2H +#pragma config BORV = VBOR_2P45 // Brown-out Reset Voltage Selection bits->Brown-out Reset Voltage (VBOR) set to 2.45V +#pragma config ZCD = OFF // ZCD Disable bit->ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON +#pragma config PPS1WAY = ON // PPSLOCK bit One-Way Set Enable bit->PPSLOCK bit can be cleared and set only once; PPS registers remain locked after one clear/set cycle +#pragma config STVREN = ON // Stack Full/Underflow Reset Enable bit->Stack full/underflow will cause Reset +#pragma config DEBUG = OFF // Debugger Enable bit->Background debugger disabled +#pragma config XINST = OFF // Extended Instruction Set Enable bit->Extended Instruction Set and Indexed Addressing Mode disabled + +// CONFIG3L +#pragma config WDTCPS = WDTCPS_31 // WDT Period selection bits->Divider ratio 1:65536; software control of WDTPS +#pragma config WDTE = OFF // WDT operating mode->WDT Disabled; SWDTEN is ignored + +// CONFIG3H +#pragma config WDTCWS = WDTCWS_7 // WDT Window Select bits->window always open (100%); software control; keyed access not required +#pragma config WDTCCS = SC // WDT input clock selector->Software Control + +// CONFIG4L +#pragma config BBSIZE = BBSIZE_512 // Boot Block Size selection bits->Boot Block size is 512 words +#pragma config BBEN = OFF // Boot Block enable bit->Boot block disabled +#pragma config SAFEN = OFF // Storage Area Flash enable bit->SAF disabled +#pragma config WRTAPP = OFF // Application Block write protection bit->Application Block not write protected + +// CONFIG4H +#pragma config WRTB = OFF // Boot Block Write Protection bit->Boot Block not write-protected +#pragma config WRTC = OFF // Configuration Register Write Protection bit->Configuration registers (300000-30000Bh) not write-protected +#pragma config WRTD = OFF // Data EEPROM Write Protection bit->Data EEPROM not write-protected +#pragma config WRTSAF = OFF // SAF Write protection bit->SAF not Write Protected +#pragma config LVP = ON // Low Voltage Programming Enable bit->Low voltage programming enabled. MCLR/VPP pin function is MCLR. MCLRE configuration bit is ignored + +// CONFIG5L +#pragma config CP = OFF // PFM and Data EEPROM Code Protection bit->PFM and Data EEPROM code protection disabled diff --git a/306-controller_interface.X/mcc_generated_files/device_config.h b/306-controller_interface.X/mcc_generated_files/device_config.h new file mode 100644 index 0000000..72f9a53 --- /dev/null +++ b/306-controller_interface.X/mcc_generated_files/device_config.h @@ -0,0 +1,55 @@ +/** + @Generated PIC10 / PIC12 / PIC16 / PIC18 MCUs Header File + + @Company: + Microchip Technology Inc. + + @File Name: + mcc.c + + @Summary: + This is the device_config.h file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs + + @Description: + This header file provides implementations for driver APIs for all modules selected in the GUI. + Generation Information : + Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 + Device : PIC18F26K83 + Driver Version : 2.00 + The generated drivers are tested against the following: + Compiler : XC8 2.36 and above or later + MPLAB : MPLAB X 6.00 +*/ + +/* + (c) 2018 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip software and any + derivatives exclusively with Microchip products. It is your responsibility to comply with third party + license terms applicable to your use of third party software (including open source software) that + may accompany Microchip software. + + THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS + FOR A PARTICULAR PURPOSE. + + IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND + WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP + HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO + THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL + CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT + OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS + SOFTWARE. +*/ + +#ifndef DEVICE_CONFIG_H +#define DEVICE_CONFIG_H + +#define _XTAL_FREQ 64000000 + +#endif /* DEVICE_CONFIG_H */ +/** + End of File +*/ diff --git a/306-controller_interface.X/mcc_generated_files/ecan.c b/306-controller_interface.X/mcc_generated_files/ecan.c new file mode 100644 index 0000000..5c28c48 --- /dev/null +++ b/306-controller_interface.X/mcc_generated_files/ecan.c @@ -0,0 +1,754 @@ +/** + ECAN Generated Driver File + + @Company + Microchip Technology Inc. + + @File Name + ecan.c + + @Summary + This is the generated driver implementation for the CAN driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs + + @Description + This source file provides APIs for CAN. + Generation Information : + Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.7 + Device : PIC18F26K83 + Driver Version : 3.0.0 + The generated drivers are tested against the following: + Compiler : XC8 2.31 and above + MPLAB : MPLAB X 5.45 +*/ + +/* + (c) 2018 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip software and any + derivatives exclusively with Microchip products. It is your responsibility to comply with third party + license terms applicable to your use of third party software (including open source software) that + may accompany Microchip software. + + THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS + FOR A PARTICULAR PURPOSE. + + IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND + WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP + HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO + THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL + CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT + OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS + SOFTWARE. +*/ + +/** + Section: Included Files +*/ + +#include +#include "ecan.h" + +static void (*RXBnInterruptHandler)(void); +static void (*RXBnOverflowHandler)(void); +static void (*BusOffHandler)(void); +static void (*TXPassiveHandler)(void); +static void (*RXPassiveHandler)(void); +static void (*TXWarningHandler)(void); +static void (*RXWarningHandler)(void); + +/** + Local Functions +*/ +static uint32_t convertReg2ExtendedCANid(uint8_t tempRXBn_EIDH, uint8_t tempRXBn_EIDL, uint8_t tempRXBn_SIDH, uint8_t tempRXBn_SIDL); +static uint32_t convertReg2StandardCANid(uint8_t tempRXBn_SIDH, uint8_t tempRXBn_SIDL); +static void convertCANid2Reg(uint32_t tempPassedInID, uint8_t canIdType, uint8_t *passedInEIDH, uint8_t *passedInEIDL, uint8_t *passedInSIDH, uint8_t *passedInSIDL); + +static void RXBnDefaultInterruptHandler(void) {} +static void RXBnOverflowDefaultHandler(void) {} +static void BusOffDefaultHandler(void) {} +static void TXPassiveDefaultHandler(void) {} +static void RXPassiveDefaultHandler(void) {} +static void TXWarningDefaultHandler(void) {} +static void RXWarningDefaultHandler(void) {} + +void ECAN_Initialize(void) +{ + CANCON = 0x80; + while (0x80 != (CANSTAT & 0xE0)); // wait until ECAN is in config mode + + /** + Mode 2 + */ + ECANCON = 0x90; + + /** + Initialize CAN I/O + */ + CIOCON = 0x00; + + /** + Mask and Filter definitions + ........................................................ + CAN ID ID Type Mask Filter Buffer + ........................................................ + 0x123 SID Acceptance Mask 0 Filter 0 FIFO + ........................................................ + */ + + /** + Configure Generic Buffers to be Transmit or Receive + */ + BSEL0 = 0x00; + /** + Mask and Filter definitions + ........................................................ + CAN ID ID Type Mask Filter Buffer + ........................................................ + ........................................................ + */ + // mask 0 is 11 bits for filter 0 and 1 + convertCANid2Reg(0x070, dSTANDARD_CAN_MSG_ID_2_0B, &RXM0EIDH, &RXM0EIDL, &RXM0SIDH, &RXM0SIDL); + // filter 0 and 1 is broadcast message + convertCANid2Reg(0x000, dSTANDARD_CAN_MSG_ID_2_0B, &RXF0EIDH, &RXF0EIDL, &RXF0SIDH, &RXF0SIDL); + convertCANid2Reg(0x010, dSTANDARD_CAN_MSG_ID_2_0B, &RXF1EIDH, &RXF1EIDL, &RXF1SIDH, &RXF1SIDL); + convertCANid2Reg(0x070, dSTANDARD_CAN_MSG_ID_2_0B, &RXF2EIDH, &RXF2EIDL, &RXF2SIDH, &RXF2SIDL); + + /** + Enable Filters + */ + RXFCON0 = 0x01; // Filter 0 is activated + RXFCON1 = 0x00; + + /** + Assign Filters to Masks + */ + MSEL0 = 0x00; // filter 0 is assigned to mask 0 + MSEL1 = 0x00; + MSEL2 = 0x00; + MSEL3 = 0x00; + + /** + Initialize CAN Timings + */ + + /** + Baud rate: 250kbps + System frequency: 64000000 + ECAN clock frequency: 64000000 + Time quanta: 8 + Sample point: 1-1-4-2 + Sample point: 75% + */ + + BRGCON1 = 0x0F; + BRGCON2 = 0x98; + BRGCON3 = 0x81; + + + ECAN_SetRXBnInterruptHandler(RXBnDefaultInterruptHandler); + PIR5bits.RXBnIF = 0; + PIE5bits.RXBnIE = 1; + + ECAN_SetRXBnOverflowHandler(RXBnOverflowDefaultHandler); + ECAN_SetBusOffHandler(BusOffDefaultHandler); + ECAN_SetTXPassiveHandler(TXPassiveDefaultHandler); + ECAN_SetRXPassiveHandler(RXPassiveDefaultHandler); + ECAN_SetTXWarningHandler(TXWarningDefaultHandler); + ECAN_SetRXWarningHandler(RXWarningDefaultHandler); + PIR5bits.ERRIF = 0; + PIE5bits.ERRIE = 1; + + CANCON = 0x00; + while (0x00 != (CANSTAT & 0xE0)); // wait until ECAN is in Normal mode + +} + /** + Section: ECAN APIs +*/ +void CAN_sleep(void) +{ + CANCON = 0x20; // request disable mode + while ((CANSTAT & 0xE0) != 0x20); // wait until ECAN is in disable mode + //Wake up from sleep should set the CAN module straight into Normal mode +} + +uint8_t CAN_transmit(uCAN_MSG *tempCanMsg) +{ + uint8_t tempEIDH = 0; + uint8_t tempEIDL = 0; + uint8_t tempSIDH = 0; + uint8_t tempSIDL = 0; + uint8_t returnValue = 0; + + if (TXB0CONbits.TXREQ != 1) + { + convertCANid2Reg(tempCanMsg->frame.id, tempCanMsg->frame.idType, &tempEIDH, &tempEIDL, &tempSIDH, &tempSIDL); + + TXB0EIDH = tempEIDH; + TXB0EIDL = tempEIDL; + TXB0SIDH = tempSIDH; + TXB0SIDL = tempSIDL; + TXB0DLC = tempCanMsg->frame.dlc | ((tempCanMsg->frame.rtr)<<6); + TXB0D0 = tempCanMsg->frame.data0; + TXB0D1 = tempCanMsg->frame.data1; + TXB0D2 = tempCanMsg->frame.data2; + TXB0D3 = tempCanMsg->frame.data3; + TXB0D4 = tempCanMsg->frame.data4; + TXB0D5 = tempCanMsg->frame.data5; + TXB0D6 = tempCanMsg->frame.data6; + TXB0D7 = tempCanMsg->frame.data7; + + TXB0CONbits.TXREQ = 1; //Set the buffer to transmit + returnValue = 1; + + } + else if (TXB1CONbits.TXREQ != 1) + { + + convertCANid2Reg(tempCanMsg->frame.id, tempCanMsg->frame.idType, &tempEIDH, &tempEIDL, &tempSIDH, &tempSIDL); + + TXB1EIDH = tempEIDH; + TXB1EIDL = tempEIDL; + TXB1SIDH = tempSIDH; + TXB1SIDL = tempSIDL; + TXB1DLC = tempCanMsg->frame.dlc | ((tempCanMsg->frame.rtr)<<6); + TXB1D0 = tempCanMsg->frame.data0; + TXB1D1 = tempCanMsg->frame.data1; + TXB1D2 = tempCanMsg->frame.data2; + TXB1D3 = tempCanMsg->frame.data3; + TXB1D4 = tempCanMsg->frame.data4; + TXB1D5 = tempCanMsg->frame.data5; + TXB1D6 = tempCanMsg->frame.data6; + TXB1D7 = tempCanMsg->frame.data7; + + TXB1CONbits.TXREQ = 1; //Set the buffer to transmit + returnValue = 1; + } + else if (TXB2CONbits.TXREQ != 1) + { + + convertCANid2Reg(tempCanMsg->frame.id, tempCanMsg->frame.idType, &tempEIDH, &tempEIDL, &tempSIDH, &tempSIDL); + + TXB2EIDH = tempEIDH; + TXB2EIDL = tempEIDL; + TXB2SIDH = tempSIDH; + TXB2SIDL = tempSIDL; + TXB2DLC = tempCanMsg->frame.dlc | ((tempCanMsg->frame.rtr)<<6); + TXB2D0 = tempCanMsg->frame.data0; + TXB2D1 = tempCanMsg->frame.data1; + TXB2D2 = tempCanMsg->frame.data2; + TXB2D3 = tempCanMsg->frame.data3; + TXB2D4 = tempCanMsg->frame.data4; + TXB2D5 = tempCanMsg->frame.data5; + TXB2D6 = tempCanMsg->frame.data6; + TXB2D7 = tempCanMsg->frame.data7; + + TXB2CONbits.TXREQ = 1; //Set the buffer to transmit + returnValue = 1; + } + + return (returnValue); +} + + +/** +Version A2 has a silicon errata +This code works for all revisions +*/ +//Fix for Errata +#define dRXB0CON_FIFO_POINTER_VALUE 0 +#define dRXB1CON_FIFO_POINTER_VALUE 1 +#define dB0CON_FIFO_POINTER_VALUE 2 +#define dB1CON_FIFO_POINTER_VALUE 3 +#define dB2CON_FIFO_POINTER_VALUE 4 +#define dB3CON_FIFO_POINTER_VALUE 5 +#define dB4CON_FIFO_POINTER_VALUE 6 +#define dB5CON_FIFO_POINTER_VALUE 7 + +uint8_t CAN_receive(uCAN_MSG *tempCanMsg) { + uint8_t returnValue = 0; + uint8_t tempECANCON; + uint8_t tempReg; + + tempReg = (CANCON & 0x0F); //get the next RX buffer to read + tempECANCON = ECANCON; //Backup + ECANCON |= (tempReg + 0x10); + + //Per Errata need to use this method to read out BxCON register + switch (tempReg) + { + case dRXB0CON_FIFO_POINTER_VALUE: + if (RXB0CONbits.RXFUL != 0) // Check RXB0 + { + if ((RXB0SIDL & 0x08) == 0x08) //If Extended Message + { + //message is extended + tempCanMsg->frame.idType = (uint8_t) dEXTENDED_CAN_MSG_ID_2_0B; + tempCanMsg->frame.id = convertReg2ExtendedCANid(RXB0EIDH, RXB0EIDL, RXB0SIDH, RXB0SIDL); + } + else + { + //message is standard + tempCanMsg->frame.idType = (uint8_t) dSTANDARD_CAN_MSG_ID_2_0B; + tempCanMsg->frame.id = convertReg2StandardCANid(RXB0SIDH, RXB0SIDL); + } + + tempCanMsg->frame.dlc = RXB0DLC & 0x0F; + tempCanMsg->frame.rtr = RXB0DLC >> 6; + tempCanMsg->frame.data0 = RXB0D0; + tempCanMsg->frame.data1 = RXB0D1; + tempCanMsg->frame.data2 = RXB0D2; + tempCanMsg->frame.data3 = RXB0D3; + tempCanMsg->frame.data4 = RXB0D4; + tempCanMsg->frame.data5 = RXB0D5; + tempCanMsg->frame.data6 = RXB0D6; + tempCanMsg->frame.data7 = RXB0D7; + RXB0CONbits.RXFUL = 0; + returnValue = 1; + } + break; + case dRXB1CON_FIFO_POINTER_VALUE: + if (RXB1CONbits.RXFUL != 0) // Check RXB1 + { + if ((RXB0SIDL & 0x08) == 0x08) //If Extended Message + { + //message is extended + tempCanMsg->frame.idType = (uint8_t) dEXTENDED_CAN_MSG_ID_2_0B; + tempCanMsg->frame.id = convertReg2ExtendedCANid(RXB0EIDH, RXB0EIDL, RXB0SIDH, RXB0SIDL); + } else { + //message is standard + tempCanMsg->frame.idType = (uint8_t) dSTANDARD_CAN_MSG_ID_2_0B; + tempCanMsg->frame.id = convertReg2StandardCANid(RXB0SIDH, RXB0SIDL); + } + + tempCanMsg->frame.dlc = RXB0DLC & 0x0F; + tempCanMsg->frame.rtr = RXB0DLC >> 6; + tempCanMsg->frame.data0 = RXB0D0; + tempCanMsg->frame.data1 = RXB0D1; + tempCanMsg->frame.data2 = RXB0D2; + tempCanMsg->frame.data3 = RXB0D3; + tempCanMsg->frame.data4 = RXB0D4; + tempCanMsg->frame.data5 = RXB0D5; + tempCanMsg->frame.data6 = RXB0D6; + tempCanMsg->frame.data7 = RXB0D7; + RXB1CONbits.RXFUL = 0; + returnValue = 1; + } + break; + case dB0CON_FIFO_POINTER_VALUE: + if (B0CONbits.RXFUL != 0) //Check B0 + { + if ((RXB0SIDL & 0x08) == 0x08) //If Extended Message + { + //message is extended + tempCanMsg->frame.idType = (uint8_t) dEXTENDED_CAN_MSG_ID_2_0B; + tempCanMsg->frame.id = convertReg2ExtendedCANid(RXB0EIDH, RXB0EIDL, RXB0SIDH, RXB0SIDL); + } else { + //message is standard + tempCanMsg->frame.idType = (uint8_t) dSTANDARD_CAN_MSG_ID_2_0B; + tempCanMsg->frame.id = convertReg2StandardCANid(RXB0SIDH, RXB0SIDL); + } + + tempCanMsg->frame.dlc = RXB0DLC & 0x0F; + tempCanMsg->frame.rtr = RXB0DLC >> 6; + tempCanMsg->frame.data0 = RXB0D0; + tempCanMsg->frame.data1 = RXB0D1; + tempCanMsg->frame.data2 = RXB0D2; + tempCanMsg->frame.data3 = RXB0D3; + tempCanMsg->frame.data4 = RXB0D4; + tempCanMsg->frame.data5 = RXB0D5; + tempCanMsg->frame.data6 = RXB0D6; + tempCanMsg->frame.data7 = RXB0D7; + B0CONbits.RXFUL = 0; + returnValue = 1; + } + break; + case dB1CON_FIFO_POINTER_VALUE: + if (B1CONbits.RXFUL != 0) //CheckB1 + { + if ((RXB0SIDL & 0x08) == 0x08) //If Extended Message + { + //message is extended + tempCanMsg->frame.idType = (uint8_t) dEXTENDED_CAN_MSG_ID_2_0B; + tempCanMsg->frame.id = convertReg2ExtendedCANid(RXB0EIDH, RXB0EIDL, RXB0SIDH, RXB0SIDL); + } + else + { + //message is standard + tempCanMsg->frame.idType = (uint8_t) dSTANDARD_CAN_MSG_ID_2_0B; + tempCanMsg->frame.id = convertReg2StandardCANid(RXB0SIDH, RXB0SIDL); + } + + tempCanMsg->frame.dlc = RXB0DLC & 0x0F; + tempCanMsg->frame.rtr = RXB0DLC >> 6; + tempCanMsg->frame.data0 = RXB0D0; + tempCanMsg->frame.data1 = RXB0D1; + tempCanMsg->frame.data2 = RXB0D2; + tempCanMsg->frame.data3 = RXB0D3; + tempCanMsg->frame.data4 = RXB0D4; + tempCanMsg->frame.data5 = RXB0D5; + tempCanMsg->frame.data6 = RXB0D6; + tempCanMsg->frame.data7 = RXB0D7; + B1CONbits.RXFUL = 0; + returnValue = 1; + } + break; + case dB2CON_FIFO_POINTER_VALUE: + if (B2CONbits.RXFUL != 0) //CheckB2 + { + if ((RXB0SIDL & 0x08) == 0x08) //If Extended Message + { + //message is extended + tempCanMsg->frame.idType = (uint8_t) dEXTENDED_CAN_MSG_ID_2_0B; + tempCanMsg->frame.id = convertReg2ExtendedCANid(RXB0EIDH, RXB0EIDL, RXB0SIDH, RXB0SIDL); + } + else + { + //message is standard + tempCanMsg->frame.idType = (uint8_t) dSTANDARD_CAN_MSG_ID_2_0B; + tempCanMsg->frame.id = convertReg2StandardCANid(RXB0SIDH, RXB0SIDL); + } + + tempCanMsg->frame.dlc = RXB0DLC & 0x0F; + tempCanMsg->frame.rtr = RXB0DLC >> 6; + tempCanMsg->frame.data0 = RXB0D0; + tempCanMsg->frame.data1 = RXB0D1; + tempCanMsg->frame.data2 = RXB0D2; + tempCanMsg->frame.data3 = RXB0D3; + tempCanMsg->frame.data4 = RXB0D4; + tempCanMsg->frame.data5 = RXB0D5; + tempCanMsg->frame.data6 = RXB0D6; + tempCanMsg->frame.data7 = RXB0D7; + B2CONbits.RXFUL = 0; + returnValue = 1; + } + break; + case dB3CON_FIFO_POINTER_VALUE: + if (B3CONbits.RXFUL != 0) //CheckB3 + { + if ((RXB0SIDL & 0x08) == 0x08) //If Extended Message + { + //message is extended + tempCanMsg->frame.idType = (uint8_t) dEXTENDED_CAN_MSG_ID_2_0B; + tempCanMsg->frame.id = convertReg2ExtendedCANid(RXB0EIDH, RXB0EIDL, RXB0SIDH, RXB0SIDL); + } + else + { + //message is standard + tempCanMsg->frame.idType = (uint8_t) dSTANDARD_CAN_MSG_ID_2_0B; + tempCanMsg->frame.id = convertReg2StandardCANid(RXB0SIDH, RXB0SIDL); + } + + tempCanMsg->frame.dlc = RXB0DLC & 0x0F; + tempCanMsg->frame.rtr = RXB0DLC >> 6; + tempCanMsg->frame.data0 = RXB0D0; + tempCanMsg->frame.data1 = RXB0D1; + tempCanMsg->frame.data2 = RXB0D2; + tempCanMsg->frame.data3 = RXB0D3; + tempCanMsg->frame.data4 = RXB0D4; + tempCanMsg->frame.data5 = RXB0D5; + tempCanMsg->frame.data6 = RXB0D6; + tempCanMsg->frame.data7 = RXB0D7; + B3CONbits.RXFUL = 0; + returnValue = 1; + } + break; + case dB4CON_FIFO_POINTER_VALUE: + if (B4CONbits.RXFUL != 0) //CheckB4 + { + if ((RXB0SIDL & 0x08) == 0x08) //If Extended Message + { + //message is extended + tempCanMsg->frame.idType = (uint8_t) dEXTENDED_CAN_MSG_ID_2_0B; + tempCanMsg->frame.id = convertReg2ExtendedCANid(RXB0EIDH, RXB0EIDL, RXB0SIDH, RXB0SIDL); + } + else + { + //message is standard + tempCanMsg->frame.idType = (uint8_t) dSTANDARD_CAN_MSG_ID_2_0B; + tempCanMsg->frame.id = convertReg2StandardCANid(RXB0SIDH, RXB0SIDL); + } + + tempCanMsg->frame.dlc = RXB0DLC & 0x0F; + tempCanMsg->frame.rtr = RXB0DLC >> 6; + tempCanMsg->frame.data0 = RXB0D0; + tempCanMsg->frame.data1 = RXB0D1; + tempCanMsg->frame.data2 = RXB0D2; + tempCanMsg->frame.data3 = RXB0D3; + tempCanMsg->frame.data4 = RXB0D4; + tempCanMsg->frame.data5 = RXB0D5; + tempCanMsg->frame.data6 = RXB0D6; + tempCanMsg->frame.data7 = RXB0D7; + B4CONbits.RXFUL = 0; + returnValue = 1; + } + break; + case dB5CON_FIFO_POINTER_VALUE: + if (B5CONbits.RXFUL != 0) //CheckB5 + { + if ((RXB0SIDL & 0x08) == 0x08) //If Extended Message + { + //message is extended + tempCanMsg->frame.idType = (uint8_t) dEXTENDED_CAN_MSG_ID_2_0B; + tempCanMsg->frame.id = convertReg2ExtendedCANid(RXB0EIDH, RXB0EIDL, RXB0SIDH, RXB0SIDL); + } + else + { + //message is standard + tempCanMsg->frame.idType = (uint8_t) dSTANDARD_CAN_MSG_ID_2_0B; + tempCanMsg->frame.id = convertReg2StandardCANid(RXB0SIDH, RXB0SIDL); + } + + tempCanMsg->frame.dlc = RXB0DLC & 0x0F; + tempCanMsg->frame.rtr = RXB0DLC >> 6; + tempCanMsg->frame.data0 = RXB0D0; + tempCanMsg->frame.data1 = RXB0D1; + tempCanMsg->frame.data2 = RXB0D2; + tempCanMsg->frame.data3 = RXB0D3; + tempCanMsg->frame.data4 = RXB0D4; + tempCanMsg->frame.data5 = RXB0D5; + tempCanMsg->frame.data6 = RXB0D6; + tempCanMsg->frame.data7 = RXB0D7; + B5CONbits.RXFUL = 0; + returnValue = 1; + } + break; + } + + ECANCON = tempECANCON; + return (returnValue); +} + +uint8_t CAN_messagesInBuffer(void) { + uint8_t messageCount = 0; + if (RXB0CONbits.RXFUL != 0) //CheckRXB0 + { + messageCount++; + } + if (RXB1CONbits.RXFUL != 0) //CheckRXB1 + { + messageCount++; + } + if (B0CONbits.RXFUL_TXBIF != 0) //CheckB0 + { + messageCount++; + } + if (B1CONbits.RXFUL_TXBIF != 0) //CheckB1 + { + messageCount++; + } + if (B2CONbits.RXFUL_TXBIF != 0) //CheckB2 + { + messageCount++; + } + if (B3CONbits.RXFUL_TXBIF != 0) //CheckB3 + { + messageCount++; + } + if (B4CONbits.RXFUL_TXBIF != 0) //CheckB4 + { + messageCount++; + } + if (B5CONbits.RXFUL_TXBIF != 0) //CheckB5 + { + messageCount++; + } + return (messageCount); +} + +uint8_t CAN_isBusOff(void) +{ + uint8_t returnValue = 0; + + //COMSTAT bit 5 TXBO: Transmitter Bus-Off bit + //1 = Transmit error counter > 255 + //0 = Transmit error counter less then or equal to 255 + + if (COMSTATbits.TXBO == 1) { + returnValue = 1; + } + return (returnValue); +} + +uint8_t CAN_isRXErrorPassive(void) +{ + uint8_t returnValue = 0; + + //COMSTAT bit 3 RXBP: Receiver Bus Passive bit + //1 = Receive error counter > 127 + //0 = Receive error counter less then or equal to 127 + + if (COMSTATbits.RXBP == 1) { + returnValue = 1; + } + return (returnValue); +} + +uint8_t CAN_isTXErrorPassive(void) +{ + uint8_t returnValue = 0; + + //COMSTAT bit 4 TXBP: Transmitter Bus Passive bit + //1 = Transmit error counter > 127 + //0 = Transmit error counter less then or equal to 127 + + if (COMSTATbits.TXBP == 1) + { + returnValue = 1; + } + return (returnValue); +} + +/** +Internal functions +*/ + +static uint32_t convertReg2ExtendedCANid(uint8_t tempRXBn_EIDH, uint8_t tempRXBn_EIDL, uint8_t tempRXBn_SIDH, uint8_t tempRXBn_SIDL) { + uint32_t returnValue = 0; + uint32_t ConvertedID = 0; + uint8_t CAN_standardLo_ID_lo2bits; + uint8_t CAN_standardLo_ID_hi3bits; + + CAN_standardLo_ID_lo2bits = (uint8_t)(tempRXBn_SIDL & 0x03); + CAN_standardLo_ID_hi3bits = (uint8_t)(tempRXBn_SIDL >> 5); + ConvertedID = (uint32_t)(tempRXBn_SIDH << 3); + ConvertedID = ConvertedID + CAN_standardLo_ID_hi3bits; + ConvertedID = (ConvertedID << 2); + ConvertedID = ConvertedID + CAN_standardLo_ID_lo2bits; + ConvertedID = (ConvertedID << 8); + ConvertedID = ConvertedID + tempRXBn_EIDH; + ConvertedID = (ConvertedID << 8); + ConvertedID = ConvertedID + tempRXBn_EIDL; + returnValue = ConvertedID; + return (returnValue); +} + +static uint32_t convertReg2StandardCANid(uint8_t tempRXBn_SIDH, uint8_t tempRXBn_SIDL) { + uint32_t returnValue = 0; + uint32_t ConvertedID; + //if standard message (11 bits) + //EIDH = 0 + EIDL = 0 + SIDH + upper three bits SIDL (3rd bit needs to be clear) + //1111 1111 111 + ConvertedID = (uint32_t)(tempRXBn_SIDH << 3); + ConvertedID = ConvertedID + (uint32_t)(tempRXBn_SIDL >> 5); + returnValue = ConvertedID; + return (returnValue); +} + +static void convertCANid2Reg(uint32_t tempPassedInID, uint8_t canIdType, uint8_t *passedInEIDH, uint8_t *passedInEIDL, uint8_t *passedInSIDH, uint8_t *passedInSIDL) { + uint8_t wipSIDL = 0; + + if (canIdType == dEXTENDED_CAN_MSG_ID_2_0B) + { + //EIDL + *passedInEIDL = 0xFF & tempPassedInID; //CAN_extendedLo_ID_TX1 = &HFF And CAN_UserEnter_ID_TX1 + tempPassedInID = tempPassedInID >> 8; //CAN_UserEnter_ID_TX1 = CAN_UserEnter_ID_TX1 >> 8 + + //EIDH + *passedInEIDH = 0xFF & tempPassedInID; //CAN_extendedHi_ID_TX1 = &HFF And CAN_UserEnter_ID_TX1 + tempPassedInID = tempPassedInID >> 8; //CAN_UserEnter_ID_TX1 = CAN_UserEnter_ID_TX1 >> 8 + + //SIDL + //push back 5 and or it + wipSIDL = 0x03 & tempPassedInID; + tempPassedInID = tempPassedInID << 3; //CAN_UserEnter_ID_TX1 = CAN_UserEnter_ID_TX1 << 3 + wipSIDL = (0xE0 & tempPassedInID) + wipSIDL; + wipSIDL = (uint8_t)(wipSIDL + 0x08); // TEMP_CAN_standardLo_ID_TX1 = TEMP_CAN_standardLo_ID_TX1 + &H8 + *passedInSIDL = (uint8_t)(0xEB & wipSIDL); //CAN_standardLo_ID_TX1 = &HEB And TEMP_CAN_standardLo_ID_TX1 + + //SIDH + tempPassedInID = tempPassedInID >> 8; + *passedInSIDH = 0xFF & tempPassedInID; + } + else //(canIdType == dSTANDARD_CAN_MSG_ID_2_0B) + { + *passedInEIDH = 0; + *passedInEIDL = 0; + tempPassedInID = tempPassedInID << 5; + *passedInSIDL = 0xFF & tempPassedInID; + tempPassedInID = tempPassedInID >> 8; + *passedInSIDH = 0xFF & tempPassedInID; + } +} + +void ECAN_SetRXBnInterruptHandler(void (*handler)(void)) +{ + RXBnInterruptHandler = handler; +} + +void ECAN_RXBnI_ISR(void) +{ + RXBnInterruptHandler(); + PIR5bits.RXBnIF = 0; // The ECAN hardware overrides the setting of this bit (to '1') when any receive buffer is not empty. +} + +void ECAN_SetRXBnOverflowHandler(void (*handler)(void)) +{ + RXBnOverflowHandler = handler; +} + +void ECAN_SetBusOffHandler(void (*handler)(void)) +{ + BusOffHandler = handler; +} + +void ECAN_SetTXPassiveHandler(void (*handler)(void)) +{ + TXPassiveHandler = handler; +} + +void ECAN_SetRXPassiveHandler(void (*handler)(void)) +{ + RXPassiveHandler = handler; +} + +void ECAN_SetTXWarningHandler(void (*handler)(void)) +{ + TXWarningHandler = handler; +} + +void ECAN_SetRXWarningHandler(void (*handler)(void)) +{ + RXWarningHandler = handler; +} + +void ECAN_ERRI_ISR(void) +{ + if (COMSTATbits.RXB1OVFL) + { + RXBnOverflowHandler(); + COMSTATbits.RXB1OVFL = 0; // In mode 2, this clears RXBnOVFL + } + + if (COMSTATbits.TXBO) + { + BusOffHandler(); + } + + if (COMSTATbits.TXBP) + { + TXPassiveHandler(); + } + + if (COMSTATbits.RXBP) + { + RXPassiveHandler(); + } + + if (COMSTATbits.TXWARN) + { + TXWarningHandler(); + } + + if (COMSTATbits.RXWARN) + { + RXWarningHandler(); + } + + PIR5bits.ERRIF = 0; +} + + diff --git a/306-controller_interface.X/mcc_generated_files/ecan.h b/306-controller_interface.X/mcc_generated_files/ecan.h new file mode 100644 index 0000000..f619bfa --- /dev/null +++ b/306-controller_interface.X/mcc_generated_files/ecan.h @@ -0,0 +1,589 @@ +/** + ECAN Generated Driver API Header File + + @Company + Microchip Technology Inc. + + @File Name + ecan.h + + @Summary + This is the generated header file for the ECAN driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs + + @Description + This header file provides APIs driver for ECAN. + Generation Information : + Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.7 + Device : PIC18F26K83 + Driver Version : 3.0.0 + The generated drivers are tested against the following: + Compiler : XC8 2.31 and above + MPLAB : MPLAB X 5.45 +*/ + +/* + (c) 2018 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip software and any + derivatives exclusively with Microchip products. It is your responsibility to comply with third party + license terms applicable to your use of third party software (including open source software) that + may accompany Microchip software. + + THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS + FOR A PARTICULAR PURPOSE. + + IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND + WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP + HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO + THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL + CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT + OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS + SOFTWARE. +*/ + +#ifndef ECAN_H +#define ECAN_H + + +/** + Section: Included Files +*/ + +#include +#include + +/** + +Global Defines + +*/ +typedef union { + + struct { + uint8_t idType; + uint32_t id; + uint8_t dlc; + uint8_t data0; + uint8_t data1; + uint8_t data2; + uint8_t data3; + uint8_t data4; + uint8_t data5; + uint8_t data6; + uint8_t data7; + uint8_t rtr; + } frame; + uint8_t array[15]; +} uCAN_MSG; + +/** + Defines +*/ + +#define dSTANDARD_CAN_MSG_ID_2_0B 1 +#define dEXTENDED_CAN_MSG_ID_2_0B 2 + +/** + Section: ECAN APIs +*/ + +/** + @Summary + Initializes the ECAN module. + + @Description + This routine sets all the set parameters to the ECAN module. + + @Preconditions + None + + @Param + None + + @Returns + None + + @Example + + ECAN_Initialize(); + +*/ +void ECAN_Initialize(void); + +/** + + @Summary + CAN_sleep + + @Description + Puts the CAN module to sleep + + @Param + None + + @Returns + None + + @Example + + CAN_init(); + + +*/ + +void CAN_sleep(void); + +/** + @Summary + CAN_transmit + + @Description + Transmits out sCAN_MSG + + @Param + Pointer to a sCAN_MSG + + @Returns + True or False if message was loaded to transmit buffer + + @Example + + uCAN_MSG txMessage; + CAN_transmit(&txMessage); + +*/ +uint8_t CAN_transmit(uCAN_MSG *tempCanMsg); + + +/** + + @Summary + CAN_receive + + @Description + Receives CAN messages + + @Param + Pointer to a sCAN_MSG + + @Returns + True or False for a new message + + @Example + + uCAN_MSG rxMessage; + CAN_receive(&rxMessage); + + +*/ +uint8_t CAN_receive(uCAN_MSG *tempCanMsg); + +/** + + @Summary + CAN_messagesInBuffer + + @Description + Checks to see how many messages are in the buffer + + @Param + None + + @Returns + Returns total number of messages in the buffers + + @Example + + uint8_t nrMsg; + nrMsg = CAN_messagesInBuffer(); + +*/ +uint8_t CAN_messagesInBuffer(void); + +/** + + @Summary + CAN_isBusOff + + @Description + Checks to see if module is busoff + + @Param + None + + @Returns + True if module is in Busoff, False is if it is not + + @Example + + uint8_t busOff; + busOff = CAN_isBusOff(); + + +*/ + +uint8_t CAN_isBusOff(void); + +/** + + @Summary + CAN_isRXErrorPassive + + @Description + Checks to see if module is RX Error Passive + + @Param + None + + @Returns + True if module is in RX Error Passive, False is if it is not + + @Example + + uint8_t errRxPasive; + errRxPasive = CAN_isRXErrorPassive(); + + + */ + +uint8_t CAN_isRXErrorPassive(void); + +/** + + @Summary + CAN_isTXErrorPassive + + @Description + Checks to see if module is TX Error Passive + + @Param + None + + @Returns + True if module is in TX Error Passive, False is if it is not + + @Example + + uint8_t errTxPasive; + errTxPasive = CAN_isTXErrorPassive(); + + +*/ + +uint8_t CAN_isTXErrorPassive(void); + +/** + @Summary + ECAN_SetRXBnInterruptHandler + + @Description + Sets the ECAN Receive buffer n interrupt handler + + @Param + Address of the callback routine + + @Returns + None + + @Example + + volatile bool customRXBnFlag = false; + + void CustomRXBnInterruptHandler(void) + { + customRXBnFlag = true; + // ... + } + + void main(void) + { + // ... + ECAN_SetRXBnInterruptHandler(CustomRXBnInterruptHandler); + + while (1) + { + if (customRXBnFlag) { + customRXBnFlag = false; + // ... + } + } + } + +*/ +void ECAN_SetRXBnInterruptHandler(void (*handler)(void)); + +/** + @Summary + ECAN_RXBnI_ISR + + @Description + Implements the ECAN Receive buffer n interrupt service routine + + @Param + None + + @Returns + None +*/ +void ECAN_RXBnI_ISR(void); + +/** + @Summary + ECAN_SetRXBnOverflowHandler + + @Description + Sets the ECAN Receive buffer n overflow interrupt handler + + @Param + Address of the callback routine + + @Returns + None + + @Example + + volatile bool customRXBnOverflowFlag = false; + + void CustomRXBnOverflowHandler(void) + { + customRXBnOverflowFlag = true; + // ... + } + + void main(void) + { + // ... + ECAN_SetRXBnOverflowHandler(CustomRXBnOverflowHandler); + + while (1) + { + if (customRXBnOverflowFlag) { + customRXBnOverflowFlag = false; + // ... + } + } + } + +*/ +void ECAN_SetRXBnOverflowHandler(void (*handler)(void)); + +/** + @Summary + ECAN_SetBusOffHandler + + @Description + Sets the ECAN Bus off interrupt handler + + @Param + Address of the callback routine + + @Returns + None + + @Example + + volatile bool customBusOffFlag = false; + + void CustomBusOffHandler(void) + { + customBusOffFlag = true; + // ... + } + + void main(void) + { + // ... + ECAN_SetBusOffHandler(CustomBusOffHandler); + + while (1) + { + if (customBusOffFlag) { + customBusOffFlag = false; + // ... + } + } + } + +*/ +void ECAN_SetBusOffHandler(void (*handler)(void)); + +/** + @Summary + ECAN_SetTXPassiveHandler + + @Description + Sets the ECAN TX passive interrupt handler + + @Param + Address of the callback routine + + @Returns + None + + @Example + + volatile bool customTXPassiveFlag = false; + + void CustomTXPassiveHandler(void) + { + customTXPassiveFlag = true; + // ... + } + + void main(void) + { + // ... + ECAN_SetTXPassiveHandler(CustomTXPassiveHandler); + + while (1) + { + if (customTXPassiveFlag) { + customTXPassiveFlag = false; + // ... + } + } + } + +*/ +void ECAN_SetTXPassiveHandler(void (*handler)(void)); + +/** + @Summary + ECAN_SetRXPassiveHandler + + @Description + Sets the ECAN RX passive interrupt handler + + @Param + Address of the callback routine + + @Returns + None + + @Example + + volatile bool customRXPassiveFlag = false; + + void CustomRXPassiveHandler(void) + { + customRXPassiveFlag = true; + // ... + } + + void main(void) + { + // ... + ECAN_SetRXPassiveHandler(CustomRXPassiveHandler); + + while (1) + { + if (customRXPassiveFlag) { + customRXPassiveFlag = false; + // ... + } + } + } + +*/ +void ECAN_SetRXPassiveHandler(void (*handler)(void)); + +/** + @Summary + ECAN_SetTXWarningHandler + + @Description + Sets the ECAN TX warning interrupt handler + + @Param + Address of the callback routine + + @Returns + None + + @Example + + volatile bool customTXWarningFlag = false; + + void CustomTXWarningHandler(void) + { + customTXWarningFlag = true; + // ... + } + + void main(void) + { + // ... + ECAN_SetTXWarningHandler(CustomTXWarningHandler); + + while (1) + { + if (customTXWarningFlag) { + customTXWarningFlag = false; + // ... + } + } + } + +*/ +void ECAN_SetTXWarningHandler(void (*handler)(void)); + +/** + @Summary + ECAN_SetRXWarningHandler + + @Description + Sets the ECAN RX warning interrupt handler + + @Param + Address of the callback routine + + @Returns + None + + @Example + + volatile bool customRXWarningFlag = false; + + void CustomRXWarningHandler(void) + { + customRXWarningFlag = true; + // ... + } + + void main(void) + { + // ... + ECAN_SetRXWarningHandler(CustomRXWarningHandler); + + while (1) + { + if (customRXWarningFlag) { + customRXWarningFlag = false; + // ... + } + } + } + +*/ +void ECAN_SetRXWarningHandler(void (*handler)(void)); + +/** + @Summary + ECAN_ERRI_ISR + + @Description + Implements the ECAN Module error interrupt service routine + + @Param + None + + @Returns + None +*/ +void ECAN_ERRI_ISR(void); + + +#endif // ECAN_H diff --git a/306-controller_interface.X/mcc_generated_files/interrupt_manager.c b/306-controller_interface.X/mcc_generated_files/interrupt_manager.c new file mode 100644 index 0000000..db7e86a --- /dev/null +++ b/306-controller_interface.X/mcc_generated_files/interrupt_manager.c @@ -0,0 +1,80 @@ +/** + Generated Interrupt Manager Source File + + @Company: + Microchip Technology Inc. + + @File Name: + interrupt_manager.c + + @Summary: + This is the Interrupt Manager file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs + + @Description: + This header file provides implementations for global interrupt handling. + For individual peripheral handlers please see the peripheral driver for + all modules selected in the GUI. + Generation Information : + Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 + Device : PIC18F26K83 + Driver Version : 2.04 + The generated drivers are tested against the following: + Compiler : XC8 2.36 and above or later + MPLAB : MPLAB X 6.00 +*/ + +/* + (c) 2018 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip software and any + derivatives exclusively with Microchip products. It is your responsibility to comply with third party + license terms applicable to your use of third party software (including open source software) that + may accompany Microchip software. + + THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS + FOR A PARTICULAR PURPOSE. + + IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND + WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP + HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO + THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL + CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT + OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS + SOFTWARE. +*/ + +#include "interrupt_manager.h" +#include "mcc.h" + +void INTERRUPT_Initialize (void) +{ + // Disable Interrupt Priority Vectors (16CXXX Compatibility Mode) + INTCON0bits.IPEN = 0; +} + +void __interrupt() INTERRUPT_InterruptManager (void) +{ + // interrupt handler + if(PIE3bits.TMR0IE == 1 && PIR3bits.TMR0IF == 1) + { + TMR0_ISR(); + } + else if(PIE5bits.ERRIE == 1 && PIR5bits.ERRIF == 1) + { + ECAN_ERRI_ISR(); + } + else if(PIE5bits.RXBnIE == 1 && PIR5bits.RXBnIF == 1) + { + ECAN_RXBnI_ISR(); + } + else + { + //Unhandled Interrupt + } +} +/** + End of File +*/ diff --git a/306-controller_interface.X/mcc_generated_files/interrupt_manager.h b/306-controller_interface.X/mcc_generated_files/interrupt_manager.h new file mode 100644 index 0000000..babb6f2 --- /dev/null +++ b/306-controller_interface.X/mcc_generated_files/interrupt_manager.h @@ -0,0 +1,92 @@ +/** + Generated Interrupt Manager Header File + + @Company: + Microchip Technology Inc. + + @File Name: + interrupt_manager.h + + @Summary: + This is the Interrupt Manager file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs + + @Description: + This header file provides implementations for global interrupt handling. + For individual peripheral handlers please see the peripheral driver for + all modules selected in the GUI. + Generation Information : + Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 + Device : PIC18F26K83 + Driver Version : 2.03 + The generated drivers are tested against the following: + Compiler : XC8 2.36 and above or later + MPLAB : MPLAB X 6.00 +*/ + +/* + (c) 2018 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip software and any + derivatives exclusively with Microchip products. It is your responsibility to comply with third party + license terms applicable to your use of third party software (including open source software) that + may accompany Microchip software. + + THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS + FOR A PARTICULAR PURPOSE. + + IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND + WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP + HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO + THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL + CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT + OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS + SOFTWARE. +*/ + +#ifndef INTERRUPT_MANAGER_H +#define INTERRUPT_MANAGER_H + + +/** + * @Param + none + * @Returns + none + * @Description + This macro will enable global interrupts. + * @Example + INTERRUPT_GlobalInterruptEnable(); + */ +#define INTERRUPT_GlobalInterruptEnable() (INTCON0bits.GIE = 1) + +/** + * @Param + none + * @Returns + none + * @Description + This macro will disable global interrupts. + * @Example + INTERRUPT_GlobalInterruptDisable(); + */ +#define INTERRUPT_GlobalInterruptDisable() (INTCON0bits.GIE = 0) + +/** + * @Param + none + * @Returns + none + * @Description + Initializes PIC18 peripheral interrupt priorities; enables/disables priority vectors + * @Example + INTERRUPT_Initialize(); + */ +void INTERRUPT_Initialize (void); + +#endif // INTERRUPT_MANAGER_H +/** + End of File +*/ diff --git a/306-controller_interface.X/mcc_generated_files/mcc.c b/306-controller_interface.X/mcc_generated_files/mcc.c new file mode 100644 index 0000000..e2cbde5 --- /dev/null +++ b/306-controller_interface.X/mcc_generated_files/mcc.c @@ -0,0 +1,97 @@ +/** + @Generated PIC10 / PIC12 / PIC16 / PIC18 MCUs Source File + + @Company: + Microchip Technology Inc. + + @File Name: + mcc.c + + @Summary: + This is the mcc.c file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs + + @Description: + This header file provides implementations for driver APIs for all modules selected in the GUI. + Generation Information : + Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 + Device : PIC18F26K83 + Driver Version : 2.00 + The generated drivers are tested against the following: + Compiler : XC8 2.36 and above or later + MPLAB : MPLAB X 6.00 +*/ + +/* + (c) 2018 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip software and any + derivatives exclusively with Microchip products. It is your responsibility to comply with third party + license terms applicable to your use of third party software (including open source software) that + may accompany Microchip software. + + THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS + FOR A PARTICULAR PURPOSE. + + IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND + WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP + HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO + THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL + CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT + OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS + SOFTWARE. +*/ + +#include "mcc.h" + + +void SYSTEM_Initialize(void) +{ + INTERRUPT_Initialize(); + PMD_Initialize(); + PIN_MANAGER_Initialize(); + OSCILLATOR_Initialize(); + TMR0_Initialize(); + ECAN_Initialize(); +} + +void OSCILLATOR_Initialize(void) +{ + // NOSC HFINTOSC; NDIV 1; + OSCCON1 = 0x60; + // CSWHOLD may proceed; SOSCPWR Low power; + OSCCON3 = 0x00; + // MFOEN disabled; LFOEN disabled; ADOEN disabled; SOSCEN disabled; EXTOEN disabled; HFOEN disabled; + OSCEN = 0x00; + // HFFRQ 64_MHz; + OSCFRQ = 0x08; + // TUN 0; + OSCTUNE = 0x00; +} + +void PMD_Initialize(void) +{ + // CLKRMD CLKR enabled; SYSCMD SYSCLK enabled; SCANMD SCANNER enabled; FVRMD FVR enabled; IOCMD IOC enabled; CRCMD CRC enabled; HLVDMD HLVD enabled; NVMMD NVM enabled; + PMD0 = 0x00; + // NCO1MD DDS(NCO1) enabled; TMR0MD TMR0 enabled; TMR1MD TMR1 enabled; TMR4MD TMR4 enabled; TMR5MD TMR5 enabled; TMR2MD TMR2 enabled; TMR3MD TMR3 enabled; TMR6MD TMR6 enabled; + PMD1 = 0x00; + // ZCDMD ZCD enabled; DACMD DAC enabled; CMP1MD CMP1 enabled; ADCMD ADC enabled; CMP2MD CMP2 enabled; + PMD2 = 0x00; + // CCP2MD CCP2 enabled; CCP1MD CCP1 enabled; CCP4MD CCP4 enabled; CCP3MD CCP3 enabled; PWM6MD PWM6 enabled; PWM5MD PWM5 enabled; PWM8MD PWM8 enabled; PWM7MD PWM7 enabled; + PMD3 = 0x00; + // CWG3MD CWG3 enabled; CWG2MD CWG2 enabled; CWG1MD CWG1 enabled; + PMD4 = 0x00; + // U2MD UART2 enabled; U1MD UART1 enabled; SPI1MD SPI1 enabled; I2C2MD I2C2 enabled; I2C1MD I2C1 enabled; + PMD5 = 0x00; + // DSMMD DSM1 enabled; CLC3MD CLC3 enabled; CLC4MD CLC4 enabled; SMT1MD SMT1 enabled; SMT2MD SMT2 enabled; CLC1MD CLC1 enabled; CLC2MD CLC2 enabled; + PMD6 = 0x00; + // DMA1MD DMA1 enabled; DMA2MD DMA2 enabled; + PMD7 = 0x00; +} + + +/** + End of File +*/ diff --git a/306-controller_interface.X/mcc_generated_files/mcc.h b/306-controller_interface.X/mcc_generated_files/mcc.h new file mode 100644 index 0000000..f681b38 --- /dev/null +++ b/306-controller_interface.X/mcc_generated_files/mcc.h @@ -0,0 +1,105 @@ +/** + @Generated PIC10 / PIC12 / PIC16 / PIC18 MCUs Header File + + @Company: + Microchip Technology Inc. + + @File Name: + mcc.h + + @Summary: + This is the mcc.h file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs + + @Description: + This header file provides implementations for driver APIs for all modules selected in the GUI. + Generation Information : + Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 + Device : PIC18F26K83 + Driver Version : 2.00 + The generated drivers are tested against the following: + Compiler : XC8 2.36 and above or later + MPLAB : MPLAB X 6.00 +*/ + +/* + (c) 2018 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip software and any + derivatives exclusively with Microchip products. It is your responsibility to comply with third party + license terms applicable to your use of third party software (including open source software) that + may accompany Microchip software. + + THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS + FOR A PARTICULAR PURPOSE. + + IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND + WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP + HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO + THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL + CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT + OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS + SOFTWARE. +*/ + +#ifndef MCC_H +#define MCC_H +#include +#include "device_config.h" +#include "pin_manager.h" +#include +#include +#include +#include "interrupt_manager.h" +#include "memory.h" +#include "tmr0.h" +#include "ecan.h" + + + +/** + * @Param + none + * @Returns + none + * @Description + Initializes the device to the default states configured in the + * MCC GUI + * @Example + SYSTEM_Initialize(void); + */ +void SYSTEM_Initialize(void); + +/** + * @Param + none + * @Returns + none + * @Description + Initializes the oscillator to the default states configured in the + * MCC GUI + * @Example + OSCILLATOR_Initialize(void); + */ +void OSCILLATOR_Initialize(void); + +/** + * @Param + none + * @Returns + none + * @Description + Initializes the PMD module to the default states configured in the + * MCC GUI + * @Example + PMD_Initialize(void); + */ +void PMD_Initialize(void); + + +#endif /* MCC_H */ +/** + End of File +*/ \ No newline at end of file diff --git a/306-controller_interface.X/mcc_generated_files/memory.c b/306-controller_interface.X/mcc_generated_files/memory.c new file mode 100644 index 0000000..b53aa2c --- /dev/null +++ b/306-controller_interface.X/mcc_generated_files/memory.c @@ -0,0 +1,206 @@ +/** + MEMORY Generated Driver File + + @Company + Microchip Technology Inc. + + @File Name + memory.c + + @Summary + This is the generated driver implementation file for the MEMORY driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs + + @Description + This file provides implementations of driver APIs for MEMORY. + Generation Information : + Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 + Device : PIC18F26K83 + Driver Version : 2.1.3 + The generated drivers are tested against the following: + Compiler : XC8 2.36 and above + MPLAB : MPLAB X 6.00 +*/ + +/* + (c) 2018 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip software and any + derivatives exclusively with Microchip products. It is your responsibility to comply with third party + license terms applicable to your use of third party software (including open source software) that + may accompany Microchip software. + + THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS + FOR A PARTICULAR PURPOSE. + + IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND + WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP + HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO + THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL + CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT + OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS + SOFTWARE. +*/ + +/** + Section: Included Files +*/ + +#include +#include "memory.h" + + +/** + Section: Flash Module APIs +*/ + +uint8_t FLASH_ReadByte(uint32_t flashAddr) +{ + NVMCON1bits.NVMREG = 2; + TBLPTRU = (uint8_t)((flashAddr & 0x00FF0000) >> 16); + TBLPTRH = (uint8_t)((flashAddr & 0x0000FF00)>> 8); + TBLPTRL = (uint8_t)(flashAddr & 0x000000FF); + + asm("TBLRD"); + + return (TABLAT); +} + +uint16_t FLASH_ReadWord(uint32_t flashAddr) +{ + return ((((uint16_t)FLASH_ReadByte(flashAddr+1))<<8)|(FLASH_ReadByte(flashAddr))); +} + +void FLASH_WriteByte(uint32_t flashAddr, uint8_t *flashRdBufPtr, uint8_t byte) +{ + uint32_t blockStartAddr = (uint32_t)(flashAddr & ((END_FLASH-1) ^ (ERASE_FLASH_BLOCKSIZE-1))); + uint8_t offset = (uint8_t)(flashAddr & (ERASE_FLASH_BLOCKSIZE-1)); + uint8_t i; + + // Entire row will be erased, read and save the existing data + for (i=0; i> 16); // Load Table point register + TBLPTRH = (uint8_t)((writeAddr & 0x0000FF00)>> 8); + TBLPTRL = (uint8_t)(writeAddr & 0x000000FF); + + // Write block of data + for (i=0; i> 16); + TBLPTRH = (uint8_t)((baseAddr & 0x0000FF00)>> 8); + TBLPTRL = (uint8_t)(baseAddr & 0x000000FF); + + NVMCON1bits.NVMREG = 2; + NVMCON1bits.WREN = 1; + NVMCON1bits.FREE = 1; + INTCON0bits.GIE = 0; // Disable interrupts + NVMCON2 = 0x55; + NVMCON2 = 0xAA; + NVMCON1bits.WR = 1; // Start program + INTCON0bits.GIE = GIEBitValue; // Restore interrupt enable + NVMCON1bits.WREN = 0; // Disable writes to memory +} + +/** + Section: Data EEPROM Module APIs +*/ + +void DATAEE_WriteByte(uint16_t bAdd, uint8_t bData) +{ + uint8_t GIEBitValue = INTCON0bits.GIE; + + NVMADRH = (uint8_t)((bAdd >> 8) & 0x03); + NVMADRL = (uint8_t)(bAdd & 0xFF); + NVMDAT = bData; + NVMCON1bits.NVMREG = 0; + NVMCON1bits.WREN = 1; + INTCON0bits.GIE = 0; // Disable interrupts + NVMCON2 = 0x55; + NVMCON2 = 0xAA; + NVMCON1bits.WR = 1; + // Wait for write to complete + while (NVMCON1bits.WR) + { + } + + NVMCON1bits.WREN = 0; + INTCON0bits.GIE = GIEBitValue; // restore interrupt enable +} + +uint8_t DATAEE_ReadByte(uint16_t bAdd) +{ + NVMADRH = (uint8_t)((bAdd >> 8) & 0x03); + NVMADRL = (uint8_t)(bAdd & 0xFF); + NVMCON1bits.NVMREG = 0; + NVMCON1bits.RD = 1; + NOP(); // NOPs may be required for latency at high frequencies + NOP(); + + return (NVMDAT); +} + +void MEMORY_Tasks( void ) +{ + /* TODO : Add interrupt handling code */ + PIR0bits.NVMIF = 0; +} +/** + End of File +*/ \ No newline at end of file diff --git a/306-controller_interface.X/mcc_generated_files/memory.h b/306-controller_interface.X/mcc_generated_files/memory.h new file mode 100644 index 0000000..5020390 --- /dev/null +++ b/306-controller_interface.X/mcc_generated_files/memory.h @@ -0,0 +1,289 @@ +/** + MEMORY Generated Driver API Header File + + @Company + Microchip Technology Inc. + + @File Name + memory.h + + @Summary + This is the generated header file for the MEMORY driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs + + @Description + This header file provides APIs for driver for MEMORY. + Generation Information : + Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 + Device : PIC18F26K83 + Driver Version : 2.1.3 + The generated drivers are tested against the following: + Compiler : XC8 2.36 and above + MPLAB : MPLAB X 6.00 +*******************************************************************************/ + +/* + (c) 2018 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip software and any + derivatives exclusively with Microchip products. It is your responsibility to comply with third party + license terms applicable to your use of third party software (including open source software) that + may accompany Microchip software. + + THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS + FOR A PARTICULAR PURPOSE. + + IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND + WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP + HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO + THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL + CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT + OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS + SOFTWARE. +*/ + +#ifndef MEMORY_H +#define MEMORY_H + +/** + Section: Included Files +*/ + +#include +#include + +#ifdef __cplusplus // Provide C++ Compatibility + + extern "C" { + +#endif + +/** + Section: Macro Declarations +*/ + +#define WRITE_FLASH_BLOCKSIZE 128 +#define ERASE_FLASH_BLOCKSIZE 128 +#define END_FLASH 0x010000 + +/** + Section: Flash Module APIs +*/ + +/** + @Summary + Reads a data byte from Flash + + @Description + This routine reads a data byte from given Flash address + + @Preconditions + None + + @Param + flashAddr - Flash program memory location from which data has to be read + + @Returns + Data byte read from given Flash address + + @Example + + uint8_t readByte; + uint32_t flashAddr = 0x7D00; + + readByte = FLASH_ReadByte(flashAddr); + +*/ +uint8_t FLASH_ReadByte(uint32_t flashAddr); + +/** + @Summary + Reads a data word from Flash + + @Description + This routine reads a data word from given Flash address + + @Preconditions + None + + @Param + flashAddr - Flash program memory location from which data has to be read + + @Returns + Data word read from given Flash address + + @Example + + uint16_t readWord; + uint32_t flashAddr = 0x7D00; + + readWord = FLASH_ReadWord(flashAddr); + +*/ +uint16_t FLASH_ReadWord(uint32_t flashAddr); + + /** + @Summary + Writes a data byte into Flash + + @Description + This routine writes the given data byte into mentioned Flash address. + + This routine intially reads block of data (from Flash) into RAM, updates + data values in RAM, and writes back updated values to Flash. + + @Preconditions + None + + @Param + flashAddr - Flash program memory location to which data has to be written + *flashRdBufPtr - Pointer to RAM buffer of size 'ERASE_FLASH_BLOCKSIZE' at least + byte - Data byte to be written in Flash + + @Returns + None + + @Example + + uint8_t writeData = 0xAA; + uint32_t flashAddr = 0x7D00; + uint8_t Buf[ERASE_FLASH_BLOCKSIZE]; + + FLASH_WriteWord(flashAddr, Buf, writeData); + +*/ +void FLASH_WriteByte(uint32_t flashAddr, uint8_t *flashRdBufPtr, uint8_t byte); + +/** + @Summary + Writes data to complete block of Flash + + @Description + This routine writes data bytes to complete block in Flash program memory + + @Preconditions + None + + @Param + writeAddr - A valid block starting address in Flash + *flashWrBufPtr - Pointer to an array of size 'WRITE_FLASH_BLOCKSIZE' at least + + @Returns + -1, if the given address is not a valid block starting address of Flash + 0, in case of valid block starting address + + @Example + + #define FLASH_ROW_ADDRESS 0x7D00 + + uint8_t wrBlockData[] = + { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F + }; + + // write to Flash memory block + FLASH_WriteBlock((uint32_t)FLASH_ROW_ADDRESS, (uint8_t *)wrBlockData); + +*/ +int8_t FLASH_WriteBlock(uint32_t writeAddr, uint8_t *flashWrBufPtr); + +/** + @Summary + Erases complete Flash program memory block + + @Description + This routine erases complete Flash program memory block + + @Preconditions + None + + @Param + baseAddr - A valid block starting address in Flash program memory + + @Returns + None + + @Example + + uint32_t flashBlockStartAddr = 0x7D00; + + FLASH_EraseBlock(flashBlockStartAddr); + +*/ +void FLASH_EraseBlock(uint32_t baseAddr); + +/** + Section: Data EEPROM Module APIs +*/ + +/** + @Summary + Writes a data byte to Data EEPROM + + @Description + This routine writes a data byte to given Data EEPROM location + + @Preconditions + None + + @Param + bAdd - Data EEPROM location to which data to be written + bData - Data to be written to Data EEPROM location + + @Returns + None + + @Example + + uint16_t dataeeAddr = 0x10; + uint8_t dataeeData = 0x55; + + DATAEE_WriteByte(dataeeAddr, dataeeData); + +*/ +void DATAEE_WriteByte(uint16_t bAdd, uint8_t bData); + +/** + @Summary + Reads a data byte from Data EEPROM + + @Description + This routine reads a data byte from given Data EEPROM location + + @Preconditions + None + + @Param + bAdd - Data EEPROM location from which data has to be read + + @Returns + Data byte read from given Data EEPROM location + + @Example + + uint16_t dataeeAddr = 0x10; + uint8_t readData; + + readData = DATAEE_ReadByte(dataeeAddr); + +*/ +uint8_t DATAEE_ReadByte(uint16_t bAdd); + +void MEMORY_Tasks(void); + +#ifdef __cplusplus // Provide C++ Compatibility + + } + +#endif + +#endif // MEMORY_H +/** + End of File +*/ + diff --git a/306-controller_interface.X/mcc_generated_files/pin_manager.c b/306-controller_interface.X/mcc_generated_files/pin_manager.c new file mode 100644 index 0000000..87f781b --- /dev/null +++ b/306-controller_interface.X/mcc_generated_files/pin_manager.c @@ -0,0 +1,124 @@ +/** + Generated Pin Manager File + + Company: + Microchip Technology Inc. + + File Name: + pin_manager.c + + Summary: + This is the Pin Manager file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs + + Description: + This header file provides implementations for pin APIs for all pins selected in the GUI. + Generation Information : + Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 + Device : PIC18F26K83 + Driver Version : 2.11 + The generated drivers are tested against the following: + Compiler : XC8 2.36 and above + MPLAB : MPLAB X 6.00 + + Copyright (c) 2013 - 2015 released Microchip Technology Inc. All rights reserved. +*/ + +/* + (c) 2018 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip software and any + derivatives exclusively with Microchip products. It is your responsibility to comply with third party + license terms applicable to your use of third party software (including open source software) that + may accompany Microchip software. + + THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS + FOR A PARTICULAR PURPOSE. + + IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND + WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP + HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO + THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL + CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT + OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS + SOFTWARE. +*/ + +#include "pin_manager.h" + + + + + +void PIN_MANAGER_Initialize(void) +{ + /** + LATx registers + */ + LATA = 0x00; + LATB = 0x00; + LATC = 0x00; + + /** + TRISx registers + */ + TRISA = 0xFF; + TRISB = 0xFE; + TRISC = 0xFF; + + /** + ANSELx registers + */ + ANSELC = 0xFF; + ANSELB = 0xF6; + ANSELA = 0x7F; + + /** + WPUx registers + */ + WPUE = 0x00; + WPUB = 0x00; + WPUA = 0x80; + WPUC = 0x00; + + /** + ODx registers + */ + ODCONA = 0x00; + ODCONB = 0x00; + ODCONC = 0x00; + + /** + SLRCONx registers + */ + SLRCONA = 0xFF; + SLRCONB = 0xFF; + SLRCONC = 0xFF; + + /** + INLVLx registers + */ + INLVLA = 0xFF; + INLVLB = 0xFF; + INLVLC = 0xFF; + INLVLE = 0x08; + + + + + + + + + CANRXPPS = 0x0B; //RB3->ECAN:CANRX; +} + +void PIN_MANAGER_IOC(void) +{ +} + +/** + End of File +*/ \ No newline at end of file diff --git a/306-controller_interface.X/mcc_generated_files/pin_manager.h b/306-controller_interface.X/mcc_generated_files/pin_manager.h new file mode 100644 index 0000000..f6407c3 --- /dev/null +++ b/306-controller_interface.X/mcc_generated_files/pin_manager.h @@ -0,0 +1,149 @@ +/** + @Generated Pin Manager Header File + + @Company: + Microchip Technology Inc. + + @File Name: + pin_manager.h + + @Summary: + This is the Pin Manager file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs + + @Description + This header file provides APIs for driver for . + Generation Information : + Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 + Device : PIC18F26K83 + Driver Version : 2.11 + The generated drivers are tested against the following: + Compiler : XC8 2.36 and above + MPLAB : MPLAB X 6.00 +*/ + +/* + (c) 2018 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip software and any + derivatives exclusively with Microchip products. It is your responsibility to comply with third party + license terms applicable to your use of third party software (including open source software) that + may accompany Microchip software. + + THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS + FOR A PARTICULAR PURPOSE. + + IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND + WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP + HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO + THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL + CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT + OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS + SOFTWARE. +*/ + +#ifndef PIN_MANAGER_H +#define PIN_MANAGER_H + +/** + Section: Included Files +*/ + +#include + +#define INPUT 1 +#define OUTPUT 0 + +#define HIGH 1 +#define LOW 0 + +#define ANALOG 1 +#define DIGITAL 0 + +#define PULL_UP_ENABLED 1 +#define PULL_UP_DISABLED 0 + +// get/set IO_RA7 aliases +#define IO_RA7_TRIS TRISAbits.TRISA7 +#define IO_RA7_LAT LATAbits.LATA7 +#define IO_RA7_PORT PORTAbits.RA7 +#define IO_RA7_WPU WPUAbits.WPUA7 +#define IO_RA7_OD ODCONAbits.ODCA7 +#define IO_RA7_ANS ANSELAbits.ANSELA7 +#define IO_RA7_SetHigh() do { LATAbits.LATA7 = 1; } while(0) +#define IO_RA7_SetLow() do { LATAbits.LATA7 = 0; } while(0) +#define IO_RA7_Toggle() do { LATAbits.LATA7 = ~LATAbits.LATA7; } while(0) +#define IO_RA7_GetValue() PORTAbits.RA7 +#define IO_RA7_SetDigitalInput() do { TRISAbits.TRISA7 = 1; } while(0) +#define IO_RA7_SetDigitalOutput() do { TRISAbits.TRISA7 = 0; } while(0) +#define IO_RA7_SetPullup() do { WPUAbits.WPUA7 = 1; } while(0) +#define IO_RA7_ResetPullup() do { WPUAbits.WPUA7 = 0; } while(0) +#define IO_RA7_SetPushPull() do { ODCONAbits.ODCA7 = 0; } while(0) +#define IO_RA7_SetOpenDrain() do { ODCONAbits.ODCA7 = 1; } while(0) +#define IO_RA7_SetAnalogMode() do { ANSELAbits.ANSELA7 = 1; } while(0) +#define IO_RA7_SetDigitalMode() do { ANSELAbits.ANSELA7 = 0; } while(0) + +// get/set IO_RB0 aliases +#define IO_RB0_TRIS TRISBbits.TRISB0 +#define IO_RB0_LAT LATBbits.LATB0 +#define IO_RB0_PORT PORTBbits.RB0 +#define IO_RB0_WPU WPUBbits.WPUB0 +#define IO_RB0_OD ODCONBbits.ODCB0 +#define IO_RB0_ANS ANSELBbits.ANSELB0 +#define IO_RB0_SetHigh() do { LATBbits.LATB0 = 1; } while(0) +#define IO_RB0_SetLow() do { LATBbits.LATB0 = 0; } while(0) +#define IO_RB0_Toggle() do { LATBbits.LATB0 = ~LATBbits.LATB0; } while(0) +#define IO_RB0_GetValue() PORTBbits.RB0 +#define IO_RB0_SetDigitalInput() do { TRISBbits.TRISB0 = 1; } while(0) +#define IO_RB0_SetDigitalOutput() do { TRISBbits.TRISB0 = 0; } while(0) +#define IO_RB0_SetPullup() do { WPUBbits.WPUB0 = 1; } while(0) +#define IO_RB0_ResetPullup() do { WPUBbits.WPUB0 = 0; } while(0) +#define IO_RB0_SetPushPull() do { ODCONBbits.ODCB0 = 0; } while(0) +#define IO_RB0_SetOpenDrain() do { ODCONBbits.ODCB0 = 1; } while(0) +#define IO_RB0_SetAnalogMode() do { ANSELBbits.ANSELB0 = 1; } while(0) +#define IO_RB0_SetDigitalMode() do { ANSELBbits.ANSELB0 = 0; } while(0) + +// get/set RB3 procedures +#define RB3_SetHigh() do { LATBbits.LATB3 = 1; } while(0) +#define RB3_SetLow() do { LATBbits.LATB3 = 0; } while(0) +#define RB3_Toggle() do { LATBbits.LATB3 = ~LATBbits.LATB3; } while(0) +#define RB3_GetValue() PORTBbits.RB3 +#define RB3_SetDigitalInput() do { TRISBbits.TRISB3 = 1; } while(0) +#define RB3_SetDigitalOutput() do { TRISBbits.TRISB3 = 0; } while(0) +#define RB3_SetPullup() do { WPUBbits.WPUB3 = 1; } while(0) +#define RB3_ResetPullup() do { WPUBbits.WPUB3 = 0; } while(0) +#define RB3_SetAnalogMode() do { ANSELBbits.ANSELB3 = 1; } while(0) +#define RB3_SetDigitalMode() do { ANSELBbits.ANSELB3 = 0; } while(0) + +/** + @Param + none + @Returns + none + @Description + GPIO and peripheral I/O initialization + @Example + PIN_MANAGER_Initialize(); + */ +void PIN_MANAGER_Initialize (void); + +/** + * @Param + none + * @Returns + none + * @Description + Interrupt on Change Handling routine + * @Example + PIN_MANAGER_IOC(); + */ +void PIN_MANAGER_IOC(void); + + + +#endif // PIN_MANAGER_H +/** + End of File +*/ \ No newline at end of file diff --git a/306-controller_interface.X/mcc_generated_files/tmr0.c b/306-controller_interface.X/mcc_generated_files/tmr0.c new file mode 100644 index 0000000..72ae03d --- /dev/null +++ b/306-controller_interface.X/mcc_generated_files/tmr0.c @@ -0,0 +1,145 @@ +/** + TMR0 Generated Driver File + + @Company + Microchip Technology Inc. + + @File Name + tmr0.c + + @Summary + This is the generated driver implementation file for the TMR0 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs + + @Description + This source file provides APIs for TMR0. + Generation Information : + Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 + Device : PIC18F26K83 + Driver Version : 3.10 + The generated drivers are tested against the following: + Compiler : XC8 2.36 and above + MPLAB : MPLAB X 6.00 +*/ + +/* + (c) 2018 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip software and any + derivatives exclusively with Microchip products. It is your responsibility to comply with third party + license terms applicable to your use of third party software (including open source software) that + may accompany Microchip software. + + THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS + FOR A PARTICULAR PURPOSE. + + IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND + WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP + HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO + THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL + CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT + OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS + SOFTWARE. +*/ + +/** + Section: Included Files +*/ + +#include +#include "tmr0.h" + + +/** + Section: TMR0 APIs +*/ + +void (*TMR0_InterruptHandler)(void); + +void TMR0_Initialize(void) +{ + // Set TMR0 to the options selected in the User Interface + + // T0CS FOSC/4; T0CKPS 1:64; T0ASYNC synchronised; + T0CON1 = 0x46; + + // TMR0H 249; + TMR0H = 0xF9; + + // TMR0L 0; + TMR0L = 0x00; + + // Clear Interrupt flag before enabling the interrupt + PIR3bits.TMR0IF = 0; + + // Enabling TMR0 interrupt. + PIE3bits.TMR0IE = 1; + + // Set Default Interrupt Handler + TMR0_SetInterruptHandler(TMR0_DefaultInterruptHandler); + + // T0OUTPS 1:10; T0EN enabled; T016BIT 8-bit; + T0CON0 = 0x89; +} + +void TMR0_StartTimer(void) +{ + // Start the Timer by writing to TMR0ON bit + T0CON0bits.T0EN = 1; +} + +void TMR0_StopTimer(void) +{ + // Stop the Timer by writing to TMR0ON bit + T0CON0bits.T0EN = 0; +} + +uint8_t TMR0_ReadTimer(void) +{ + uint8_t readVal; + + // read Timer0, low register only + readVal = TMR0L; + + return readVal; +} + +void TMR0_WriteTimer(uint8_t timerVal) +{ + // Write to Timer0 registers, low register only + TMR0L = timerVal; + } + +void TMR0_Reload(uint8_t periodVal) +{ + // Write to Timer0 registers, high register only + TMR0H = periodVal; +} + +void TMR0_ISR(void) +{ + // clear the TMR0 interrupt flag + PIR3bits.TMR0IF = 0; + if(TMR0_InterruptHandler) + { + TMR0_InterruptHandler(); + } + + // add your TMR0 interrupt custom code +} + + +void TMR0_SetInterruptHandler(void (* InterruptHandler)(void)){ + TMR0_InterruptHandler = InterruptHandler; +} + +void TMR0_DefaultInterruptHandler(void){ + // add your TMR0 interrupt custom code + // or set custom function using TMR0_SetInterruptHandler() +} + +/** + End of File +*/ \ No newline at end of file diff --git a/306-controller_interface.X/mcc_generated_files/tmr0.h b/306-controller_interface.X/mcc_generated_files/tmr0.h new file mode 100644 index 0000000..60b06d7 --- /dev/null +++ b/306-controller_interface.X/mcc_generated_files/tmr0.h @@ -0,0 +1,357 @@ +/** + TMR0 Generated Driver API Header File + + @Company + Microchip Technology Inc. + + @File Name + tmr0.h + + @Summary + This is the generated header file for the TMR0 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs + + @Description + This header file provides APIs for TMR0. + Generation Information : + Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 + Device : PIC18F26K83 + Driver Version : 3.10 + The generated drivers are tested against the following: + Compiler : XC8 2.36 and above + MPLAB : MPLAB X 6.00 +*/ + +/* + (c) 2018 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip software and any + derivatives exclusively with Microchip products. It is your responsibility to comply with third party + license terms applicable to your use of third party software (including open source software) that + may accompany Microchip software. + + THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS + FOR A PARTICULAR PURPOSE. + + IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND + WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP + HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO + THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL + CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT + OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS + SOFTWARE. +*/ + +#ifndef TMR0_H +#define TMR0_H + +/** + Section: Included Files +*/ + +#include +#include + +#ifdef __cplusplus // Provide C++ Compatibility + + extern "C" { + +#endif + + + +/** + Section: TMR0 APIs +*/ + +/** + @Summary + Initializes the TMR0. + + @Description + This function initializes the TMR0 Registers. + This function must be called before any other TMR0 function is called. + + @Preconditions + None + + @Param + None + + @Returns + None + + @Comment + + + @Example + + main() + { + // Initialize TMR0 module + TMR0_Initialize(); + + // Do something else... + } + +*/ +void TMR0_Initialize(void); + +/** + @Summary + This function starts the TMR0. + + @Description + This function starts the TMR0 operation. + This function must be called after the initialization of TMR0. + + @Preconditions + Initialize the TMR0 before calling this function. + + @Param + None + + @Returns + None + + @Example + + // Initialize TMR0 module + + // Start TMR0 + TMR0_StartTimer(); + + // Do something else... + +*/ +void TMR0_StartTimer(void); + +/** + @Summary + This function stops the TMR0. + + @Description + This function stops the TMR0 operation. + This function must be called after the start of TMR0. + + @Preconditions + Initialize the TMR0 before calling this function. + + @Param + None + + @Returns + None + + @Example + + // Initialize TMR0 module + + // Start TMR0 + TMR0_StartTimer(); + + // Do something else... + + // Stop TMR0; + TMR0_StopTimer(); + +*/ +void TMR0_StopTimer(void); + +/** + @Summary + Reads the 8 bits TMR0 register value. + + @Description + This function reads the 8 bits TMR0 register value and return it. + + @Preconditions + Initialize the TMR0 before calling this function. + + @Param + None + + @Returns + This function returns the 8 bits value of TMR0 register. + + @Example + + // Initialize TMR0 module + + // Start TMR0 + TMR0_StartTimer(); + + // Read the current value of TMR0 + if(0 == TMR0_ReadTimer()) + { + // Do something else... + + // Stop TMR0; + TMR0_StopTimer(); + } + +*/ +uint8_t TMR0_ReadTimer(void); + +/** + @Summary + Writes the 8 bits value to TMR0 register. + + @Description + This function writes the 8 bits value to TMR0 register. + This function must be called after the initialization of TMR0. + + @Preconditions + Initialize the TMR0 before calling this function. + + @Param + timerVal - Value to write into TMR0 register. + + @Returns + None + + @Example + + #define PERIOD 0x80 + #define ZERO 0x00 + + while(1) + { + // Read the TMR0 register + if(ZERO == TMR0_ReadTimer()) + { + // Do something else... + + // Write the TMR0 register + TMR0_WriteTimer(PERIOD); + } + + // Do something else... + } + +*/ +void TMR0_WriteTimer(uint8_t timerVal); + +/** + @Summary + Load value to Period Register. + + @Description + This function writes the value to TMR0H register. + This function must be called after the initialization of TMR0. + + @Preconditions + Initialize the TMR0 before calling this function. + + @Param + periodVal - Value to load into TMR0 register. + + @Returns + None + + + @Example + + while(1) + { + if(TMR0IF) + { + // Do something else... + + // clear the TMR0 interrupt flag + TMR0IF = 0; + + // Change the period value of TMR0 + TMR0_Reload(0x80); + } + } + +*/ +void TMR0_Reload(uint8_t periodVal); + + +/** + @Summary + Timer Interrupt Service Routine + + @Description + Timer Interrupt Service Routine is called by the Interrupt Manager. + + @Preconditions + Initialize the TMR0 module with interrupt before calling this isr. + + @Param + None + + @Returns + None + */ +void TMR0_ISR(void); + + +/** + @Summary + Set Timer Interrupt Handler + + @Description + This sets the function to be called during the ISR + + @Preconditions + Initialize the TMR0 module with interrupt before calling this. + + @Param + Address of function to be set + + @Returns + None +*/ + void TMR0_SetInterruptHandler(void (* InterruptHandler)(void)); + +/** + @Summary + Timer Interrupt Handler + + @Description + This is a function pointer to the function that will be called during the ISR + + @Preconditions + Initialize the TMR0 module with interrupt before calling this isr. + + @Param + None + + @Returns + None +*/ +extern void (*TMR0_InterruptHandler)(void); + +/** + @Summary + Default Timer Interrupt Handler + + @Description + This is the default Interrupt Handler function + + @Preconditions + Initialize the TMR0 module with interrupt before calling this isr. + + @Param + None + + @Returns + None +*/ +void TMR0_DefaultInterruptHandler(void); + +#ifdef __cplusplus // Provide C++ Compatibility + + } + +#endif + +#endif // TMR0_H +/** + End of File +*/ \ No newline at end of file diff --git a/306-controller_interface.X/nbproject/configurations.xml b/306-controller_interface.X/nbproject/configurations.xml new file mode 100644 index 0000000..4e1f9cf --- /dev/null +++ b/306-controller_interface.X/nbproject/configurations.xml @@ -0,0 +1,248 @@ + + + + + + app/blcontrol.h + + + + board/button/buttonsm.h + board/button/button.h + + + board/led/led.h + + + + factory/factory.h + + + mcc_generated_files/pin_manager.h + mcc_generated_files/device_config.h + mcc_generated_files/mcc.h + mcc_generated_files/interrupt_manager.h + mcc_generated_files/tmr0.h + mcc_generated_files/ecan.h + mcc_generated_files/memory.h + + + + + xf/event.h + xf/xf.h + xf/ireactive.h + + + + + + + app/blcontrol.c + + + + board/button/button.c + board/button/buttonsm.c + + + board/led/led.c + + + + factory/factory.c + + + mcc_generated_files/interrupt_manager.c + mcc_generated_files/tmr0.c + mcc_generated_files/pin_manager.c + mcc_generated_files/device_config.c + mcc_generated_files/mcc.c + mcc_generated_files/ecan.c + mcc_generated_files/memory.c + + + + + xf/event.c + xf/xf.c + + main.c + + + Makefile + ss22x0.mc3 + ss22ep.mc3 + + + + board + led + factory + middleware + app + xf + + Makefile + + + + localhost + PIC18F26K83 + + + PICkit3PlatformTool + XC8 + 2.41 + 3 + + + + + + + + + + + + + + + false + false + + + + + + + false + false + + false + + false + false + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/306-controller_interface.X/nbproject/project.xml b/306-controller_interface.X/nbproject/project.xml new file mode 100644 index 0000000..042e146 --- /dev/null +++ b/306-controller_interface.X/nbproject/project.xml @@ -0,0 +1,34 @@ + + + com.microchip.mplab.nbide.embedded.makeproject + + + 306-controller_interface + 89baf189-5cb3-4a17-9f0a-47659c07dc79 + 0 + c + + h + + ISO-8859-1 + + + board + led + factory + middleware + app + xf + + + + default + 2 + + + + false + + + + diff --git a/306-controller_interface.X/ss22ep.mc3 b/306-controller_interface.X/ss22ep.mc3 new file mode 100644 index 0000000..25fb154 --- /dev/null +++ b/306-controller_interface.X/ss22ep.mc3 @@ -0,0 +1,17228 @@ + + + + + DMA CHANNEL1 + class com.microchip.mcc.mcu8.dmaManager.submodule.DMAModules + + + DMA CHANNEL2 + class com.microchip.mcc.mcu8.dmaManager.submodule.DMAModules + + + DMA Manager + class com.microchip.mcc.mcu8.dmaManager.DMA + + + ECAN + class com.microchip.mcc.mcu8.modules.can.CAN + + + INTERNAL OSCILLATOR + class com.microchip.mcc.mcu8.systemManager.osc.Osc + + + Interrupt Module + class com.microchip.mcc.mcu8.interruptManager_K42.InterruptManager + + + MEMORY + class com.microchip.mcc.mcu8.modules.memory.MEMORY + + + PMD + class com.microchip.mcc.mcu8.systemManager.pmd.PMD + + + Pin Module + class com.microchip.mcc.mcu8.pinManager.PinManager + + + RESET + class com.microchip.mcc.mcu8.systemManager.reset.RESET + + + System Module + class com.microchip.mcc.mcu8.systemManager.SystemManager + + + TMR0 + class com.microchip.mcc.mcu8.modules.tmr0_mid0.TMR0 + + + WWDT + class com.microchip.mcc.mcu8.systemManager.wwdt.WWDT + + + + + + + + + ISR_DMA CHANNEL1_DMAAI + + + + ISR_DMA CHANNEL1_DMADCNTI + + + + ISR_DMA CHANNEL1_DMAORI + + + + ISR_DMA CHANNEL1_DMASCNTI + + + + 10 + + + + 11 + + + + 45 + + + + 47 + + + + 40 + + + + 41 + + + + 42 + + + + 43 + + + + 44 + + + + 46 + + + + 35 + + + + 67 + + + + 74 + + + + 77 + + + + 38 + + + + 69 + + + + 76 + + + + 78 + + + + 12 + + + + 48 + + + + 6 + + + + 3 + + + + 37 + + + + 68 + + + + 75 + + + + 19 + + + + 17 + + + + 18 + + + + 16 + + + + 55 + + + + 53 + + + + 54 + + + + 52 + + + + 25 + + + + 26 + + + + 23 + + + + 24 + + + + 58 + + + + 59 + + + + 56 + + + + 57 + + + + 8 + + + + 39 + + + + 70 + + + + 7 + + + + 1 + + + + 36 + + + + 4 + + + + 0 + + + + 2 + + + + 5 + + + + 13 + + + + 14 + + + + 15 + + + + 49 + + + + 50 + + + + 51 + + + + 22 + + + + 20 + + + + 21 + + + + 31 + + + + 32 + + + + 33 + + + + 34 + + + + 64 + + + + 65 + + + + 66 + + + + 71 + + + + 72 + + + + 73 + + + + 30 + + + + 29 + + + + 27 + + + + 28 + + + + 63 + + + + 62 + + + + 60 + + + + 61 + + + + 9 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 2 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 2 + + + + 1 + + + + 0 + + + + 2 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 10 + + + + 11 + + + + 45 + + + + 47 + + + + 40 + + + + 41 + + + + 42 + + + + 43 + + + + 44 + + + + 46 + + + + 35 + + + + 67 + + + + 74 + + + + 77 + + + + 38 + + + + 69 + + + + 76 + + + + 78 + + + + 12 + + + + 48 + + + + 6 + + + + 3 + + + + 37 + + + + 68 + + + + 75 + + + + 19 + + + + 17 + + + + 18 + + + + 16 + + + + 55 + + + + 53 + + + + 54 + + + + 52 + + + + 25 + + + + 26 + + + + 23 + + + + 24 + + + + 58 + + + + 59 + + + + 56 + + + + 57 + + + + 8 + + + + 39 + + + + 70 + + + + 7 + + + + 1 + + + + 36 + + + + 4 + + + + 0 + + + + 2 + + + + 5 + + + + 13 + + + + 14 + + + + 15 + + + + 49 + + + + 50 + + + + 51 + + + + 22 + + + + 20 + + + + 21 + + + + 31 + + + + 32 + + + + 33 + + + + 34 + + + + 64 + + + + 65 + + + + 66 + + + + 71 + + + + 72 + + + + 73 + + + + 30 + + + + 29 + + + + 27 + + + + 28 + + + + 63 + + + + 62 + + + + 60 + + + + 61 + + + + 9 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + disabled + + + + disabled + + + + -1 + + + + 1 + + + + None + + + + disabled + + + + not in progress + + + + disabled + + + + disabled + + + + not in progress + + + + unchanged + + + + not cleared + + + + unchanged + + + + GPR + + + + not cleared + + + + disabled + + + + disabled + + + + -1 + + + + 1 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + disabled + + + + disabled + + + + -1 + + + + 1 + + + + disabled + + + + disabled + + + + -1 + + + + 1 + + + + None + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + ISR_DMA CHANNEL2_DMAAI + + + + ISR_DMA CHANNEL2_DMADCNTI + + + + ISR_DMA CHANNEL2_DMAORI + + + + ISR_DMA CHANNEL2_DMASCNTI + + + + 10 + + + + 11 + + + + 45 + + + + 47 + + + + 40 + + + + 41 + + + + 42 + + + + 43 + + + + 44 + + + + 46 + + + + 35 + + + + 67 + + + + 74 + + + + 77 + + + + 38 + + + + 69 + + + + 76 + + + + 78 + + + + 12 + + + + 48 + + + + 6 + + + + 3 + + + + 37 + + + + 68 + + + + 75 + + + + 19 + + + + 17 + + + + 18 + + + + 16 + + + + 55 + + + + 53 + + + + 54 + + + + 52 + + + + 25 + + + + 26 + + + + 23 + + + + 24 + + + + 58 + + + + 59 + + + + 56 + + + + 57 + + + + 8 + + + + 39 + + + + 70 + + + + 7 + + + + 1 + + + + 36 + + + + 4 + + + + 0 + + + + 2 + + + + 5 + + + + 13 + + + + 14 + + + + 15 + + + + 49 + + + + 50 + + + + 51 + + + + 22 + + + + 20 + + + + 21 + + + + 31 + + + + 32 + + + + 33 + + + + 34 + + + + 64 + + + + 65 + + + + 66 + + + + 71 + + + + 72 + + + + 73 + + + + 30 + + + + 29 + + + + 27 + + + + 28 + + + + 63 + + + + 62 + + + + 60 + + + + 61 + + + + 9 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 2 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 2 + + + + 1 + + + + 0 + + + + 2 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 10 + + + + 11 + + + + 45 + + + + 47 + + + + 40 + + + + 41 + + + + 42 + + + + 43 + + + + 44 + + + + 46 + + + + 35 + + + + 67 + + + + 74 + + + + 77 + + + + 38 + + + + 69 + + + + 76 + + + + 78 + + + + 12 + + + + 48 + + + + 6 + + + + 3 + + + + 37 + + + + 68 + + + + 75 + + + + 19 + + + + 17 + + + + 18 + + + + 16 + + + + 55 + + + + 53 + + + + 54 + + + + 52 + + + + 25 + + + + 26 + + + + 23 + + + + 24 + + + + 58 + + + + 59 + + + + 56 + + + + 57 + + + + 8 + + + + 39 + + + + 70 + + + + 7 + + + + 1 + + + + 36 + + + + 4 + + + + 0 + + + + 2 + + + + 5 + + + + 13 + + + + 14 + + + + 15 + + + + 49 + + + + 50 + + + + 51 + + + + 22 + + + + 20 + + + + 21 + + + + 31 + + + + 32 + + + + 33 + + + + 34 + + + + 64 + + + + 65 + + + + 66 + + + + 71 + + + + 72 + + + + 73 + + + + 30 + + + + 29 + + + + 27 + + + + 28 + + + + 63 + + + + 62 + + + + 60 + + + + 61 + + + + 9 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + disabled + + + + disabled + + + + -1 + + + + 1 + + + + None + + + + disabled + + + + not in progress + + + + disabled + + + + disabled + + + + not in progress + + + + unchanged + + + + not cleared + + + + unchanged + + + + GPR + + + + not cleared + + + + disabled + + + + disabled + + + + -1 + + + + 1 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + disabled + + + + disabled + + + + -1 + + + + 1 + + + + disabled + + + + disabled + + + + -1 + + + + 1 + + + + None + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + {"dataArray":[{"DMA Channels":{"data":{"isDisable":"true","options":"--NONE--","text":"DMA CHANNEL1","value":"false"},"id":"DMA Channels_rowCount_0"},"Src Module":{"data":{"isDisable":"true","options":"--NONE--,TMR0,ECAN,MEMORY","text":"--NONE--","value":"--NONE--"},"id":"Src Module_rowCount_0"},"Src Region":{"data":{"isDisable":"true","options":"SFR#disabled,GPR#enabled,Program Flash#enabled,Data EEPROM#enabled","text":"GPR","value":"GPR"},"id":"Src Region_rowCount_0"},"Src SFR":{"Src SFR":{"isDisable":"true","options":"","text":"","value":""},"data":{"isDisable":"true","options":"","text":"","value":""},"id":"Src SFR_rowCount_0"},"Src VarName":{"data":{"isDisable":"true","options":"","text":"SrcVarName0","value":"SrcVarName0"},"Src VarName":{"isDisable":"true","options":"","text":"SrcVarName0","value":"SrcVarName0"},"id":"Src VarName_rowCount_0"},"Src VarSize":{"data":{"isDisable":"true","options":"","text":"10","value":"10"},"id":"Src VarSize_rowCount_0","Src VarSize":{"isDisable":"true","options":"","text":"10","value":"10"}},"Src Address":{"data":{"isDisable":"true","options":"","text":"Enter Address0","value":"Enter Address0"},"id":"Src Address_rowCount_0","Src Address":{"isDisable":"true","options":"","text":"Enter Address0","value":"Enter Address0"}},"Src Mode":{"Src Mode":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"data":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"id":"Src Mode_rowCount_0"},"Src Message Size":{"data":{"isDisable":"true","options":"","text":"1","value":"1"},"Src Message Size":{"isDisable":"true","options":"","text":"1","value":"1"},"id":"Src Message Size_rowCount_0"},"Dst Module":{"data":{"isDisable":"true","options":"--NONE--,TMR0,ECAN,MEMORY","text":"--NONE--","value":"--NONE--"},"id":"Dst Module_rowCount_0"},"Dst Region":{"data":{"isDisable":"true","options":"SFR,GPR","text":"GPR","value":"GPR"},"id":"Dst Region_rowCount_0"},"Dst SFR":{"Dst SFR":{"isDisable":"true","options":"","text":"","value":""},"data":{"isDisable":"true","options":"","text":"","value":""},"id":"Dst SFR_rowCount_0"},"Dst VarName":{"data":{"isDisable":"true","options":"","text":"DstVarName0","value":"DstVarName0"},"Dst VarName":{"isDisable":"true","options":"","text":"DstVarName0","value":"DstVarName0"},"id":"Dst VarName_rowCount_0"},"Dst VarSize":{"data":{"isDisable":"true","options":"","text":"10","value":"10"},"id":"Dst VarSize_rowCount_0","Dst VarSize":{"isDisable":"true","options":"","text":"10","value":"10"}},"Dst Mode":{"data":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"Dst Mode":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"id":"Dst Mode_rowCount_0"},"Dst Message Size":{"data":{"isDisable":"true","options":"","text":"1","value":"1"},"Dst Message Size":{"isDisable":"true","options":"","text":"1","value":"1"},"id":"Dst Message Size_rowCount_0"},"Start Trigger":{"Start Trigger":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"},"data":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"},"id":"Start Trigger_rowCount_0"},"Abort Trigger":{"data":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"},"id":"Abort Trigger_rowCount_0","Abort Trigger":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"}}},{"DMA Channels":{"data":{"isDisable":"true","options":"--NONE--","text":"DMA CHANNEL2","value":"false"},"id":"DMA Channels_rowCount_1"},"Src Module":{"data":{"isDisable":"true","options":"--NONE--,TMR0,ECAN,MEMORY","text":"--NONE--","value":"--NONE--"},"id":"Src Module_rowCount_1"},"Src Region":{"data":{"isDisable":"true","options":"SFR#disabled,GPR#enabled,Program Flash#enabled,Data EEPROM#enabled","text":"GPR","value":"GPR"},"id":"Src Region_rowCount_1"},"Src SFR":{"Src SFR":{"isDisable":"true","options":"","text":"","value":""},"data":{"isDisable":"true","options":"","text":"","value":""},"id":"Src SFR_rowCount_1"},"Src VarName":{"data":{"isDisable":"true","options":"","text":"SrcVarName1","value":"SrcVarName1"},"Src VarName":{"isDisable":"true","options":"","text":"SrcVarName1","value":"SrcVarName1"},"id":"Src VarName_rowCount_1"},"Src VarSize":{"data":{"isDisable":"true","options":"","text":"10","value":"10"},"id":"Src VarSize_rowCount_1","Src VarSize":{"isDisable":"true","options":"","text":"10","value":"10"}},"Src Address":{"data":{"isDisable":"true","options":"","text":"Enter Address1","value":"Enter Address1"},"id":"Src Address_rowCount_1","Src Address":{"isDisable":"true","options":"","text":"Enter Address1","value":"Enter Address1"}},"Src Mode":{"Src Mode":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"data":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"id":"Src Mode_rowCount_1"},"Src Message Size":{"data":{"isDisable":"true","options":"","text":"1","value":"1"},"Src Message Size":{"isDisable":"true","options":"","text":"1","value":"1"},"id":"Src Message Size_rowCount_1"},"Dst Module":{"data":{"isDisable":"true","options":"--NONE--,TMR0,ECAN,MEMORY","text":"--NONE--","value":"--NONE--"},"id":"Dst Module_rowCount_1"},"Dst Region":{"data":{"isDisable":"true","options":"SFR,GPR","text":"GPR","value":"GPR"},"id":"Dst Region_rowCount_1"},"Dst SFR":{"Dst SFR":{"isDisable":"true","options":"","text":"","value":""},"data":{"isDisable":"true","options":"","text":"","value":""},"id":"Dst SFR_rowCount_1"},"Dst VarName":{"data":{"isDisable":"true","options":"","text":"DstVarName1","value":"DstVarName1"},"Dst VarName":{"isDisable":"true","options":"","text":"DstVarName1","value":"DstVarName1"},"id":"Dst VarName_rowCount_1"},"Dst VarSize":{"data":{"isDisable":"true","options":"","text":"10","value":"10"},"id":"Dst VarSize_rowCount_1","Dst VarSize":{"isDisable":"true","options":"","text":"10","value":"10"}},"Dst Mode":{"data":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"Dst Mode":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"id":"Dst Mode_rowCount_1"},"Dst Message Size":{"data":{"isDisable":"true","options":"","text":"1","value":"1"},"Dst Message Size":{"isDisable":"true","options":"","text":"1","value":"1"},"id":"Dst Message Size_rowCount_1"},"Start Trigger":{"Start Trigger":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"},"data":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"},"id":"Start Trigger_rowCount_1"},"Abort Trigger":{"data":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"},"id":"Abort Trigger_rowCount_1","Abort Trigger":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"}}}],"type":"tableDynamicControls","key":"dmaTable"} + + + + ERRI_ISR + + + + FIFOWMI_ISR + + + + IRXI_ISR + + + + RXB0I_ISR + + + + RXB1I_ISR + + + + RXBnI_ISR + + + + TXB0I_ISR + + + + TXB1I_ISR + + + + TXB2I_ISR + + + + TXBnI_ISR + + + + WAKI_ISR + + + + Filter 0 + + + + SID + + + + Acceptance Mask 0 + + + + FIFO + + + + 250kbps + + + + 64000000 + + + + PIC18F26K83 + + + + CANTX pin will drive VDD when recessive + + + + 1000000 + + + + 8 + + + + FIFO Watermark interrupt is disabled + + + + 0 + + + + hfintosc + + + + 1 x TQ + + + + 75% + + + + 8 + + + + 64000000 + + + + 64000000 + + + + 0 + + + + enabled + + + + enabled + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 8 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 8 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 8 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 8 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 8 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 8 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 9 + + + + 10 + + + + 11 + + + + 12 + + + + 13 + + + + 14 + + + + 15 + + + + 16 + + + + 17 + + + + 18 + + + + 1 + + + + 19 + + + + 20 + + + + 21 + + + + 22 + + + + 23 + + + + 24 + + + + 25 + + + + 26 + + + + 27 + + + + 28 + + + + 2 + + + + 29 + + + + 30 + + + + 31 + + + + 32 + + + + 33 + + + + 34 + + + + 35 + + + + 36 + + + + 37 + + + + 38 + + + + 3 + + + + 39 + + + + 40 + + + + 41 + + + + 42 + + + + 43 + + + + 44 + + + + 45 + + + + 46 + + + + 47 + + + + 48 + + + + 4 + + + + 49 + + + + 50 + + + + 51 + + + + 52 + + + + 53 + + + + 54 + + + + 55 + + + + 56 + + + + 57 + + + + 58 + + + + 5 + + + + 59 + + + + 60 + + + + 61 + + + + 14 + + + + 63 + + + + 6 + + + + 7 + + + + 8 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 1 + + + + 4 + + + + 3 + + + + 2 + + + + 0 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 0 + + + + 8 + + + + 9 + + + + 1 + + + + 6 + + + + 7 + + + + 2 + + + + 15 + + + + 16 + + + + 17 + + + + 18 + + + + 19 + + + + 20 + + + + 21 + + + + 22 + + + + 23 + + + + 3 + + + + 4 + + + + 5 + + + + 0 + + + + 1 + + + + 2 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 8 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 8 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 8 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 15 + + + + 152 + + + + 129 + + + + 0 + + + + 128 + + + + 0 + + + + 0 + + + + 144 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + When a remote transmission request is received, TXREQ will be unaffected + + + + Receive buffer is open to receive a new message + + + + Receive all valid messages as per acceptance filters + + + + Received message is not a remote transmission request + + + + Message was not aborted + + + + No message was transmitted + + + + A bus error did not occur while the message was being sent + + + + Message did not lose arbitration while being sent + + + + 0 + + + + 0 + + + + Automatically cleared when the message is successfully sent + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Data length = 0 bytes + + + + This is not a remote transmission request + + + + Transmitted message will have the RTR bit cleared + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Received message is a standard identifier frame + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + When a remote transmission request is received, TXREQ will be unaffected + + + + Receive buffer is open to receive a new message + + + + Receive all valid messages as per acceptance filters + + + + Received message is not a remote transmission request + + + + Message was not aborted + + + + No message was transmitted + + + + A bus error did not occur while the message was being sent + + + + Message did not lose arbitration while being sent + + + + 0 + + + + 0 + + + + Automatically cleared when the message is successfully sent + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Data length = 0 bytes + + + + This is not a remote transmission request + + + + Transmitted message will have the RTR bit cleared + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Received message is a standard identifier frame + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + When a remote transmission request is received, TXREQ will be unaffected + + + + Receive buffer is open to receive a new message + + + + Receive all valid messages as per acceptance filters + + + + Received message is not a remote transmission request + + + + Message was not aborted + + + + No message was transmitted + + + + A bus error did not occur while the message was being sent + + + + Message did not lose arbitration while being sent + + + + 0 + + + + 0 + + + + Automatically cleared when the message is successfully sent + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Data length = 0 bytes + + + + This is not a remote transmission request + + + + Transmitted message will have the RTR bit cleared + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Received message is a standard identifier frame + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + When a remote transmission request is received, TXREQ will be unaffected + + + + Receive buffer is open to receive a new message + + + + Receive all valid messages as per acceptance filters + + + + Received message is not a remote transmission request + + + + Message was not aborted + + + + No message was transmitted + + + + A bus error did not occur while the message was being sent + + + + Message did not lose arbitration while being sent + + + + 0 + + + + 0 + + + + Automatically cleared when the message is successfully sent + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Data length = 0 bytes + + + + This is not a remote transmission request + + + + Transmitted message will have the RTR bit cleared + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Received message is a standard identifier frame + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + When a remote transmission request is received, TXREQ will be unaffected + + + + Receive buffer is open to receive a new message + + + + Receive all valid messages as per acceptance filters + + + + Received message is not a remote transmission request + + + + Message was not aborted + + + + No message was transmitted + + + + A bus error did not occur while the message was being sent + + + + Message did not lose arbitration while being sent + + + + 0 + + + + 0 + + + + Automatically cleared when the message is successfully sent + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Data length = 0 bytes + + + + This is not a remote transmission request + + + + Transmitted message will have the RTR bit cleared + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Received message is a standard identifier frame + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + When a remote transmission request is received, TXREQ will be unaffected + + + + Receive buffer is open to receive a new message + + + + Receive all valid messages as per acceptance filters + + + + Received message is not a remote transmission request + + + + Message was not aborted + + + + No message was transmitted + + + + A bus error did not occur while the message was being sent + + + + Message did not lose arbitration while being sent + + + + 0 + + + + 0 + + + + Automatically cleared when the message is successfully sent + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Data length = 0 bytes + + + + This is not a remote transmission request + + + + Transmitted message will have the RTR bit cleared + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Received message is a standard identifier frame + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Interrupt is disabled + + + + Interrupt is disabled + + + + Interrupt is disabled + + + + Interrupt is disabled + + + + Interrupt is disabled + + + + Interrupt is disabled + + + + Interrupt is disabled + + + + Interrupt is disabled + + + + TQ = (2 x 16)/FOSC + + + + Synchronization jump width time = 1 x TQ + + + + 1 x TQ + + + + Bus line is sampled once at the sample point + + + + 4 x TQ + + + + Freely programmable + + + + 2 x TQ + + + + Disable CAN bus activity wake-up feature + + + + CAN bus line filter is not used for wake-up + + + + Buffer 0 is configured in Receive mode + + + + Buffer 1 is configured in Receive mode + + + + Buffer 2 is configured in Receive mode + + + + Buffer 3 is configured in Receive mode + + + + Buffer 4 is configured in Receive mode + + + + Buffer 5 is configured in Receive mode + + + + Transmissions proceeding as normal + + + + 0 + + + + Requests Configuration Mode + + + + 0 + + + + 0 + + + + 0 + + + + Use system clock as CAN system clock + + + + CANTX1 pin will output CANTX + + + + Neither the RXWARN or the TXWARN bits are set + + + + Receive Buffer 0 has not overflowed + + + + Receive Buffer 1 has not overflowed + + + + Receive error counter LESS OR EQUAL THAN 127 + + + + Receive Buffer n has not overflowed + + + + Receive error counter LESS OR EQUAL THAN 95 + + + + Transmit error counter LESS OR EQUAL THAN 255 + + + + Transmit error counter LESS OR EQUAL THAN 127 + + + + Transmit error counter LESS OR EQUAL THAN 95 + + + + Receive Buffer 0 + + + + FIF0 Interrupt when four receive buffer remains + + + + Enhanced FIFO mode( Mode 2) + + + + enabled + + + + disabled + + + + -1 + + + + 1 + + + + disabled + + + + disabled + + + + -1 + + + + 1 + + + + disabled + + + + disabled + + + + -1 + + + + 1 + + + + Acceptance Mask 0 + + + + Acceptance Mask 0 + + + + Acceptance Mask 0 + + + + Acceptance Mask 0 + + + + Acceptance Mask 0 + + + + Acceptance Mask 0 + + + + Acceptance Mask 0 + + + + Acceptance Mask 0 + + + + Acceptance Mask 0 + + + + Acceptance Mask 0 + + + + Acceptance Mask 0 + + + + Acceptance Mask 0 + + + + Acceptance Mask 0 + + + + Acceptance Mask 0 + + + + Acceptance Mask 0 + + + + Acceptance Mask 0 + + + + Acceptance Filter 0 (RXF0) + + + + 0 + + + + Allows jump table offset between 1 and 0 + + + + No Receive Buffer 0 overflow to Receive Buffer 1 + + + + Receive buffer is open to receive a new message + + + + A remote transmission request is not received + + + + Receive all valid messages as per acceptance filters + + + + A remote transmission request is not received + + + + disabled + + + + disabled + + + + -1 + + + + 1 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Receive buffer is open to receive a new message + + + + A remote transmission request is not received + + + + Receive all valid messages as per acceptance filters + + + + A remote transmission request is not received + + + + disabled + + + + disabled + + + + -1 + + + + 1 + + + + enabled + + + + disabled + + + + -1 + + + + 1 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Filter will only accept standard ID messages + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Filter will only accept standard ID messages + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Filter will only accept standard ID messages + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Filter will only accept standard ID messages + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Filter will only accept standard ID messages + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Filter will only accept standard ID messages + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Filter will only accept standard ID messages + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Filter will only accept standard ID messages + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Filter will only accept standard ID messages + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Filter will only accept standard ID messages + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Filter will only accept standard ID messages + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Filter will only accept standard ID messages + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Filter will only accept standard ID messages + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Filter will only accept standard ID messages + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Filter will only accept standard ID messages + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Filter will only accept standard ID messages + + + + 0 + + + + 0 + + + + 0 + + + + RXB0 + + + + RXB0 + + + + RXB0 + + + + RXB0 + + + + RXB0 + + + + RXB0 + + + + RXB0 + + + + RXB0 + + + + RXB0 + + + + RXB0 + + + + RXB0 + + + + RXB0 + + + + RXB0 + + + + RXB0 + + + + RXB0 + + + + RXB0 + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Both standard and extended identifier messages will be accepted + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Both standard and extended identifier messages will be accepted + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Message was not aborted + + + + Transmit buffer has not completed transmission of a message + + + + A bus error did not occur while the message was being sent + + + + Message did not lose arbitration while being sent + + + + Priority Level 0 (lowest priority) + + + + Automatically cleared when the message is successfully sent + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Data length = 0 bytes + + + + Transmitted message will have the TXRTR bit cleared + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + disabled + + + + disabled + + + + -1 + + + + 1 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Message will transmit standard ID + + + + 0 + + + + 0 + + + + 0 + + + + Message was not aborted + + + + Transmit buffer has not completed transmission of a message + + + + A bus error did not occur while the message was being sent + + + + Message did not lose arbitration while being sent + + + + Priority Level 0 (lowest priority) + + + + Automatically cleared when the message is successfully sent + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Data length = 0 bytes + + + + Transmitted message will have the TXRTR bit cleared + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + disabled + + + + disabled + + + + -1 + + + + 1 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Message will transmit standard ID + + + + 0 + + + + 0 + + + + 0 + + + + Message was not aborted + + + + Transmit buffer has not completed transmission of a message + + + + A bus error did not occur while the message was being sent + + + + Message did not lose arbitration while being sent + + + + Priority Level 0 (lowest priority) + + + + Automatically cleared when the message is successfully sent + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Data length = 0 bytes + + + + Transmitted message will have the TXRTR bit cleared + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + disabled + + + + disabled + + + + -1 + + + + 1 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + Message will transmit standard ID + + + + 0 + + + + 0 + + + + 0 + + + + Transmit buffer interrupt is disabled + + + + Transmit buffer interrupt is disabled + + + + Transmit buffer interrupt is disabled + + + + disabled + + + + disabled + + + + -1 + + + + 1 + + + + disabled + + + + disabled + + + + -1 + + + + 1 + + + + + + + + 64000000 + + + + Oscillator not enabled + + + + HFINTOSC with HFFRQ = 64 MHz and CDIV = 1:1 + + + + 64_MHz + + + + 1000000 + + + + 64000000 + + + + 64000000 + + + + 31000 + + + + 31250 + + + + 500000 + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + internal + + + + OFF + + + + PRESENT + + + + disabled + + + + disabled + + + + 0 + + + + 7 + + + + 4 + + + + 1 + + + + 8 + + + + 5 + + + + 2 + + + + 9 + + + + 6 + + + + 3 + + + + 7 + + + + 2 + + + + 6 + + + + 5 + + + + 4 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 4 + + + + 5 + + + + 0 + + + + 1 + + + + 6 + + + + 7 + + + + 2 + + + + 8 + + + + 3 + + + + 96 + + + + 0 + + + + 0 + + + + 8 + + + + 0 + + + + 1 + + + + HFINTOSC + + + + may proceed + + + + not ready + + + + clock switching + + + + Low power + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + 64_MHz + + + + 0 + + + + 8 + + + + IVT1 + + + + disabled + + + + disabled + + + + enabled + + + + enabled + + + + 65536 + + + + 128 + + + + ISR + + + + 128 + + + + enabled + + + + 1 + + + + 0 + + + + 2 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + write + + + + access_data_eeprom + + + + do_not_initiate_read + + + + write_complete + + + + disabled + + + + normal_completion + + + + 0 + + + + 0 + + + + disabled + + + + disabled + + + + -1 + + + + 1 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + CLKR enabled + + + + CRC enabled + + + + FVR enabled + + + + HLVD enabled + + + + IOC enabled + + + + NVM enabled + + + + SCANNER enabled + + + + SYSCLK enabled + + + + DDS(NCO1) enabled + + + + TMR0 enabled + + + + TMR1 enabled + + + + TMR2 enabled + + + + TMR3 enabled + + + + TMR4 enabled + + + + TMR5 enabled + + + + TMR6 enabled + + + + ADC enabled + + + + CMP1 enabled + + + + CMP2 enabled + + + + DAC enabled + + + + ZCD enabled + + + + CCP1 enabled + + + + CCP2 enabled + + + + CCP3 enabled + + + + CCP4 enabled + + + + PWM5 enabled + + + + PWM6 enabled + + + + PWM7 enabled + + + + PWM8 enabled + + + + CWG1 enabled + + + + CWG2 enabled + + + + CWG3 enabled + + + + I2C1 enabled + + + + I2C2 enabled + + + + SPI1 enabled + + + + UART1 enabled + + + + UART2 enabled + + + + CLC1 enabled + + + + CLC2 enabled + + + + CLC3 enabled + + + + CLC4 enabled + + + + DSM1 enabled + + + + SMT1 enabled + + + + SMT2 enabled + + + + DMA1 enabled + + + + DMA2 enabled + + + + + + + + + + + + + + + + + + + + + + + + IO_RA5 + + + + IO_RA6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ISR_Pin Module_IOCI + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + input + + + + output + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + %DESELECT% + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + enabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + none + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + SOIC28 + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + enabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 12 + + + + 223 + + + + 246 + + + + 255 + + + + 11 + + + + 18 + + + + 17 + + + + 13 + + + + 8 + + + + 0 + + + + 1 + + + + 14 + + + + 15 + + + + 8 + + + + 9 + + + + 10 + + + + 19 + + + + 20 + + + + 9 + + + + 2 + + + + 255 + + + + 255 + + + + 255 + + + + 8 + + + + 8 + + + + 9 + + + + 10 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 4 + + + + 3 + + + + 5 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 51 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 255 + + + + 255 + + + + 255 + + + + 17 + + + + 16 + + + + 13 + + + + 12 + + + + 19 + + + + 20 + + + + 5 + + + + 4 + + + + 16 + + + + 13 + + + + 19 + + + + 16 + + + + 16 + + + + 21 + + + + 18 + + + + 12 + + + + 15 + + + + 191 + + + + 238 + + + + 255 + + + + 22 + + + + 23 + + + + 14 + + + + 15 + + + + 128 + + + + 0 + + + + 0 + + + + 0 + + + + 12 + + + + analog + + + + analog + + + + analog + + + + analog + + + + analog + + + + digital + + + + analog + + + + analog + + + + digital + + + + analog + + + + analog + + + + digital + + + + analog + + + + analog + + + + analog + + + + analog + + + + analog + + + + analog + + + + analog + + + + analog + + + + analog + + + + analog + + + + analog + + + + analog + + + + 11 + + + + 18 + + + + 17 + + + + 13 + + + + 8 + + + + 0 + + + + 1 + + + + 14 + + + + 15 + + + + 8 + + + + 9 + + + + 10 + + + + 19 + + + + 20 + + + + 9 + + + + 2 + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + ST_input + + + + 8 + + + + 9 + + + + 10 + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + 0 + + + + 1 + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + 4 + + + + 3 + + + + 5 + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 51 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + limited + + + + 17 + + + + 16 + + + + 13 + + + + 12 + + + + 19 + + + + 20 + + + + 5 + + + + 4 + + + + 16 + + + + 13 + + + + 19 + + + + 16 + + + + 16 + + + + 21 + + + + 18 + + + + 12 + + + + 15 + + + + input + + + + input + + + + input + + + + input + + + + input + + + + input + + + + output + + + + input + + + + output + + + + input + + + + input + + + + input + + + + output + + + + input + + + + input + + + + input + + + + input + + + + input + + + + input + + + + input + + + + input + + + + input + + + + input + + + + input + + + + 22 + + + + 23 + + + + 14 + + + + 15 + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + set + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + clear + + + + 31.0 KHz + + + + enabled + + + + 1 + + + + 0 + + + + 0 + + + + 8 + + + + 0 + + + + 32 + + + + 0 + + + + 2 + + + + 7 + + + + 5 + + + + 6 + + + + 2 + + + + 0 + + + + 4 + + + + 3 + + + + 1 + + + + 112 + + + + 32 + + + + 96 + + + + 0 + + + + 80 + + + + 16 + + + + 64 + + + + 3 + + + + 1 + + + + 0 + + + + 32 + + + + 0 + + + + 0 + + + + 8 + + + + 0 + + + + 16 + + + + 128 + + + + 0 + + + + 4 + + + + 0 + + + + 128 + + + + 0 + + + + 64 + + + + 192 + + + + 0 + + + + 16 + + + + 32 + + + + 0 + + + + 1 + + + + 0 + + + + 0 + + + + 8 + + + + 0 + + + + 2 + + + + 4 + + + + 6 + + + + 0 + + + + 8 + + + + 56 + + + + 16 + + + + 0 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 0 + + + + 1 + + + + 10 + + + + 11 + + + + 12 + + + + 13 + + + + 14 + + + + 15 + + + + 16 + + + + 17 + + + + 18 + + + + 2 + + + + 3 + + + + 31 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 8 + + + + 9 + + + + 64 + + + + 0 + + + + 96 + + + + 32 + + + + 0 + + + + 32 + + + + 1 + + + + 0 + + + + 2 + + + + 0 + + + + 4 + + + + 0 + + + + 8 + + + + 0 + + + + 8 + + + + 0 + + + + 6 + + + + 2 + + + + 5 + + + + 4 + + + + 7 + + + + 3 + + + + 16 + + + + 0 + + + + 128 + + + + 0 + + + + 1 + + + + 0 + + + + 43 + + + + 4 + + + + 191 + + + + 247 + + + + 63 + + + + 31 + + + + 47 + + + + 159 + + + + 1 + + + + OFF + + + + ON + + + + ON + + + + ON + + + + OFF + + + + HFINTOSC_64MHZ + + + + VBOR_2P45 + + + + OFF + + + + ON + + + + ON + + + + OFF + + + + OFF + + + + SBORDIS + + + + ON + + + + OFF + + + + EXTMCLR + + + + OFF + + + + PWRT_OFF + + + + SC + + + + WDTCWS_7 + + + + WDTCPS_31 + + + + OFF + + + + ON + + + + OFF + + + + OFF + + + + OFF + + + + OFF + + + + OFF + + + + BBSIZE_512 + + + + OFF + + + + OFF + + + + OFF + + + + 0 + + + + ISR + + + + 0.01 + + + + 64000000 + + + + 100000 + + + + periodMode + + + + 0.01024 + + + + 0.00004 + + + + 10 + + + + 64 + + + + 25000 + + + + 0.01 + + + + disabled + + + + 0 + + + + enabled + + + + 8-bit + + + + 1 + + + + 0 + + + + 0 + + + + 1 + + + + 1 + + + + 0 + + + + 0 + + + + 9 + + + + 10 + + + + 11 + + + + 12 + + + + 13 + + + + 14 + + + + 15 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 8 + + + + 1 + + + + 0 + + + + 0 + + + + 10 + + + + 7 + + + + 4 + + + + 14 + + + + 1 + + + + 11 + + + + 8 + + + + 5 + + + + 15 + + + + 2 + + + + 12 + + + + 9 + + + + 6 + + + + 3 + + + + 13 + + + + 7 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 0 + + + + 1 + + + + 137 + + + + 70 + + + + 249 + + + + 0 + + + + 8-bit + + + + enabled + + + + low + + + + 1:10 + + + + synchronised + + + + 1:64 + + + + FOSC/4 + + + + 249 + + + + 0 + + + + enabled + + + + disabled + + + + -1 + + + + 1 + + + + 2.11406 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 5 + + + + 15 + + + + 2 + + + + 12 + + + + 9 + + + + 6 + + + + 16 + + + + 3 + + + + 13 + + + + 0 + + + + 10 + + + + 7 + + + + 17 + + + + 4 + + + + 14 + + + + 1 + + + + 11 + + + + 8 + + + + 18 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 2 + + + + 7 + + + + 6 + + + + 5 + + + + 4 + + + + 3 + + + + 2 + + + + 1 + + + + 0 + + + + 48 + + + + 0 + + + + 0 + + + + WDT reset has not occurred + + + + WDT window violation reset has not occurred + + + + 1:32 + + + + OFF + + + + LFINTOSC 31kHz + + + + Window delay time 87.5% + + + + + main.c + cae37ae3b36cf22e97e106633433f5c00a66dd5d38ec353eb67fbbb0d88bde4d + + + mcc_generated_files\device_config.c + 39a6d1181ef5eab59c7dde2c52a9ea889465d4da43262200f3322abc45e77739 + + + mcc_generated_files\device_config.h + 89c6172ff575ce515b93f2fbc85dcedc2978e58a8e0e1fbdc52e42511ae3bc05 + + + mcc_generated_files\ecan.c + ea62f50d319e1e537d7632774728ad6a779f442e896d043dbdea8066d028a6c6 + + + mcc_generated_files\ecan.h + aa9a50aae81bab76b876ea6123777af7d6a6d0a58fe953be27e8b88776395b2e + + + mcc_generated_files\interrupt_manager.c + df04edcd2c7d85ef90a8dbe4e46f1b1c9487b872153f4f2321249a4ce0d9635f + + + mcc_generated_files\interrupt_manager.h + 9c2f1ae45f2ac887bb3e8b3763e1a394a6a22ffe4e9ae1c20c336fe6f12da1aa + + + mcc_generated_files\mcc.c + cc9ed44843b509879e6a3f676b561ecde91e1df88d855cf7eca77e1afc8920ca + + + mcc_generated_files\mcc.h + a2db7e36e878f686c2bf0c2ef586ef1c6570fa2f27119b4be7b52af6403091a4 + + + mcc_generated_files\memory.c + 17fb4759c4719b77287f6c4be48edfbcf117b5b8398b771c434f23aceac256e0 + + + mcc_generated_files\memory.h + fbbca4e9d7ce92ddcc637d82b694a1f5cbefa75710a8a18bb1dc9ab5161f0924 + + + mcc_generated_files\pin_manager.c + 30d27d3c212d3420d65a30996dd68e9c3ba572d0d2bf50924ad025e552b9dcbf + + + mcc_generated_files\pin_manager.h + 76c9c709283a0d30fc6bf8d663b1394044aa806dbd1282fad68c1ebb0a221d36 + + + mcc_generated_files\tmr0.c + e0b4d075e819024ae77ea60a2c01182fdca45b783980cb50358d0a614736339d + + + mcc_generated_files\tmr0.h + 6661ab783aae9f11e952805f9bca14209ec06551939552123056eefd5524fff8 + + + \ No newline at end of file diff --git a/306-controller_interface.X/xf/event.c b/306-controller_interface.X/xf/event.c new file mode 100644 index 0000000..f668ad5 --- /dev/null +++ b/306-controller_interface.X/xf/event.c @@ -0,0 +1,61 @@ +#include "event.h" +#define NULL ((void*)(0)) + +void Event_init(struct Event_* me) +{ + me->id = NULLEVENT; + me->delay = 0; + me->target = NULL; + me->data = 0x0; + me->processEvent = NULL; +} + +void Event_setData(Event* me, int64_t data) +{ + me->data = data; +} + +int64_t Event_getData(Event* me) +{ + return me->data; +} + +void Event_setPE(Event* me, processEventT processEvent) +{ + me->processEvent = processEvent; +} + +void Event_setTarget(Event* me, void* target) +{ + me->target = target; +} + +processEventT Event_getPE(Event* me) +{ + return me->processEvent; +} + +void* Event_getTarget(Event* me) +{ + return me->target; +} + +void Event_setId(Event* me, evIDT eventID) +{ + me->id = eventID; +} + +evIDT Event_getId(Event* me) +{ + return me->id; +} + +void Event_setDelay(Event* me, uint16_t delay) +{ + me->delay = delay; +} + +uint16_t Event_getDelay(Event* me) +{ + return me->delay; +} \ No newline at end of file diff --git a/306-controller_interface.X/xf/event.h b/306-controller_interface.X/xf/event.h new file mode 100644 index 0000000..a37cc0f --- /dev/null +++ b/306-controller_interface.X/xf/event.h @@ -0,0 +1,35 @@ +#include +#include +#include "ireactive.h" + +#ifndef EVENT_ONCE +#define EVENT_ONCE + +typedef uint8_t evIDT; +#define NULLEVENT 0 // no event + +struct Event_ +{ + evIDT id; + processEventT processEvent; + void* target; + uint16_t delay; + int64_t data; +}; + +typedef struct Event_ Event; + +//public methods +void Event_init(Event* me); +void Event_setTarget(Event* me, void* target); +void Event_setPE(Event* me, processEventT processEvent); +void* Event_getTarget(Event* me); +processEventT Event_getPE(Event* me); +void Event_setId(Event* me, evIDT eventID); +evIDT Event_getId(Event* me); +void Event_setDelay(Event* me, uint16_t delay); +uint16_t Event_getDelay(Event* me); +void Event_setData(Event* me, int64_t data); +int64_t Event_getData(Event* me); + +#endif \ No newline at end of file diff --git a/306-controller_interface.X/xf/ireactive.h b/306-controller_interface.X/xf/ireactive.h new file mode 100644 index 0000000..c8850bc --- /dev/null +++ b/306-controller_interface.X/xf/ireactive.h @@ -0,0 +1,8 @@ +#ifndef IREACTIVE_ONCE +#define IREACTIVE_ONCE + +struct Event_; + +typedef bool (*processEventT)(struct Event_* ev); + +#endif \ No newline at end of file diff --git a/306-controller_interface.X/xf/xf.c b/306-controller_interface.X/xf/xf.c new file mode 100644 index 0000000..3074898 --- /dev/null +++ b/306-controller_interface.X/xf/xf.c @@ -0,0 +1,292 @@ +/******************************************************************************/ +/* FILENAME : xf.h */ +/*----------------------------------------------------------------------------*/ +/* GOAL : Offers the femto XF functions (for PIC CPU) */ +/*----------------------------------------------------------------------------*/ +/* AUTHOR : Medard Rieder / Pascal Sartoretti */ +/*----------------------------------------------------------------------------*/ +/* DATE: : original (Medard Rieder 08.2011) */ +/* corrections & simplified (Pascal Sartoretti 06.2016) */ +/******************************************************************************/ +#include // boolean types +#include "xf.h" +#include "../mcc_generated_files/mcc.h" + +/* + * private methods of the XF + */ + +/******************************************************************************/ +/* FUNCTION : Push an event on the events queue */ +/* INPUT : ev - the event number (not 0) */ +/* inISR - (true if called in an ISR, else false) */ +/* OUTPUT : return false if the queue was full, else true */ +/* COMMENTS : - */ +/******************************************************************************/ +bool XF_pushEvent(Event ev, bool inISR, TimerID* tmid); +/******************************************************************************/ +/* FUNCTION : Pop an event on the events queue */ +/* INPUT : inISR - (true if called in an ISR, else false) */ +/* OUTPUT : return the next waiting event if any, else 0 */ +/* COMMENTS : - */ +/******************************************************************************/ +Event XF_popEvent(bool inISR); +/******************************************************************************/ +/* FUNCTION : Post a timer in timers queue */ +/* INPUT : tm - time before event arrives */ +/* ev - event to post */ +/* inISR - (true if called in an ISR, else false) */ +/* OUTPUT : return the timer Id used */ +/* COMMENTS : - */ +/******************************************************************************/ +TimerID XF_scheduleTimer(Time tm, Event ev, bool inISR); + +/******************************************************************************/ +/* FUNCTION : Switch of the interrupts */ +/* INPUT : inISR - (true if called in an ISR, else f */ +/* OUTPUT : none */ +/* COMMENTS : - */ +/******************************************************************************/ +static void ENTERCRITICAL(bool inISR); +/******************************************************************************/ +/* FUNCTION : Switch on the interrupts */ +/* INPUT : inISR - (true if called in an ISR, else f */ +/* OUTPUT : none */ +/* COMMENTS : - */ +/******************************************************************************/ +static void LEAVECRITICAL(bool inISR); + + +/* + * the XF instance + */ +XF theXF; // really the XF + + + +/******************************************************************************/ +/* FUNCTION : Init the XF structure */ +/* INPUT : - */ +/* OUTPUT : - */ +/* COMMENTS : Have to be called once */ +/******************************************************************************/ +void XF_init() +{ + int i; + for (i=0; i 0) + { + Event_setDelay(&ev,0); + *tmid = XF_scheduleTimer(tm, ev, inISR); + } + else + { + ENTERCRITICAL(inISR); + + temp = (theXF.in+1) % (uint8_t)(sizeof(theXF.eventQueue) / sizeof(Event)); + if(temp == theXF.out) + { + LEAVECRITICAL(inISR); + return false; + } + theXF.eventQueue[theXF.in] = ev; + theXF.in = temp; + LEAVECRITICAL(inISR); + } + return true; +} + +/******************************************************************************/ +/* FUNCTION : Pop an event on the events queue */ +/* INPUT : inISR - (true if called in an ISR, else false) */ +/* OUTPUT : return the next waiting event if any, else 0 */ +/* COMMENTS : - */ +/******************************************************************************/ +Event XF_popEvent(bool inISR) +{ + Event ev; + ev.id = NULLEVENT; + ev.target = NULL; + ev.processEvent = NULL; + + ENTERCRITICAL(inISR); + if(theXF.in == theXF.out) + { + LEAVECRITICAL(inISR); + return ev; + } + ev = theXF.eventQueue[theXF.out]; + theXF.out = (theXF.out + 1)%(uint8_t)(sizeof(theXF.eventQueue) / sizeof(Event)); + LEAVECRITICAL(inISR); + return ev; +} + +/******************************************************************************/ +/* FUNCTION : Post a timer in timers queue */ +/* INPUT : tm - time before event arrives */ +/* ev - event to post */ +/* inISR - (true if called in an ISR, else false) */ +/* OUTPUT : return the timer Id used */ +/* COMMENTS : - */ +/******************************************************************************/ +TimerID XF_scheduleTimer(Time tm, Event ev, bool inISR) +{ + uint8_t i; + + ENTERCRITICAL(inISR); + for (i=0; i // usage of standard types +#include // usage of boolean types +#include "../mcc_generated_files/mcc.h" +#include "event.h" + +#define Time uint16_t // time type +#define TimerID uint8_t // identifier of timer (position in buffer) + +typedef struct Timer_ // timer structure +{ + Time tm; // time + Event ev; // event to post +} Timer; +/*----------------------------------------------------------------------------*/ +/* depending on usage, change MAXTIMER and MAXEVENT */ +/*----------------------------------------------------------------------------*/ +#define MAXTIMER 8 // number of timers in our system +#define MAXEVENT 12 // number of events in our system + +#define NULLTIMER 0 // no value for time +#define TICKINTERVAL 10 // this is the ticktimers duration + + +/*----------------------------------------------------------------------------*/ +typedef struct XF // the XF structure +{ + Timer timerList[MAXTIMER]; // the timers + Event eventQueue[MAXEVENT]; // the events + uint8_t in; // the events in pointer + uint8_t out; // the events out pointer +} XF; + +/******************************************************************************/ +/* FUNCTION : Init the XF structure */ +/* INPUT : - */ +/* OUTPUT : - */ +/* COMMENTS : Have to be called once */ +/******************************************************************************/ +void XF_init(); + +/******************************************************************************/ +/* FUNCTION : Remove a timer in timers queue */ +/* INPUT : id - the timer id to remove */ +/* inISR - (true if called in an ISR, else false) */ +/* OUTPUT : - */ +/* COMMENTS : - */ +/******************************************************************************/ +void XF_unscheduleTimer(TimerID id, bool inISR); +/******************************************************************************/ +/* FUNCTION : Decrement timers to post events if time elapsed */ +/* INPUT : - */ +/* OUTPUT : - */ +/* COMMENTS : This function has to be called from the timer ISR */ +/******************************************************************************/ +void XF_decrementAndQueueTimers(); + +/********************************************************************************/ +/* FUNCTION : POST an Event */ +/* INPUT : target - the address of the object with the state machine */ +/* processEvent - function pointer of the state machine function */ +/* id - the id of the event */ +/* delay - the delay if the event is a timeout event */ +/* data - user data */ +/* OUTPUT : TimerId - the id of the timeout if the event is a timeout */ +/* COMMENTS : */ +/********************************************************************************/ +TimerID POST(void* target, processEventT processEvent, uint8_t id, Time delay, int64_t data); + +void XF_executeOnce(); +#endif +