diff options
author | Camil Staps | 2016-08-22 22:21:37 +0200 |
---|---|---|
committer | Camil Staps | 2016-08-22 22:21:37 +0200 |
commit | de5e94a6b1a8f95aa6b10e0c8ee26b79b0772ebc (patch) | |
tree | 9c9ba025b7a3cbbb7be1b860f164702e17af0aa7 |
Initial commit; t6963c + blink an led
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | firmware/.gitignore | 1 | ||||
-rw-r--r-- | firmware/Makefile | 70 | ||||
-rw-r--r-- | firmware/main.c | 52 | ||||
m--------- | firmware/t6963c | 0 | ||||
-rw-r--r-- | firmware/t6963c_specific.c | 38 | ||||
-rw-r--r-- | firmware/t6963c_specific.h | 68 |
7 files changed, 232 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..c9f056f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "firmware/t6963c"] + path = firmware/t6963c + url = https://github.com/camilstaps/T6963C_PIC diff --git a/firmware/.gitignore b/firmware/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/firmware/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/firmware/Makefile b/firmware/Makefile new file mode 100644 index 0000000..919d167 --- /dev/null +++ b/firmware/Makefile @@ -0,0 +1,70 @@ +MCU:=24FJ256DA206 + +IDIR=. +ODIR=build + +CC:=xc16-gcc +CFLAGS:=\ + -Wall\ + -I$(IDIR)\ + -mcpu=$(MCU)\ + -g\ + -msmart-io=1\ + -Wl,--script=p$(MCU).gld\ + -Wl,--gc-sections\ + -Wl,--stack=16\ + -Wl,--local-stack\ + -Wl,--check-sections\ + -Wl,--data-init\ + -Wl,--pack-data\ + -Wl,--handles\ + -Wl,--isr\ + -Wl,--no-gc-sections\ + -Wl,--fill-upper=0\ + -Wl,--stackguard=16\ + -Wl,--no-force-link\ + -Wl,--smart-io + +BIN2HEX:=xc16-bin2hex + +_HEX:=main.hex +HEX:=$(patsubst %,$(ODIR)/%,$(_HEX)) + +_DEPS:=\ + t6963c_specific.h\ + t6963c/t6963c.h\ + t6963c/terminal.h +DEPS:=$(patsubst %,$(IDIR)/%,$(_DEPS)) + +_OBJ:=main.o $(subst .h,.o,$(_DEPS)) +OBJ:=$(patsubst %,$(ODIR)/%,$(_OBJ)) + +_ASM:=$(subst .o,.s,$(_OBJ)) +ASM:=$(patsubst %,$(ODIR)/%,$(_ASM)) + +.PHONY: all all_hex all_assembly clean + +all: all_hex + +all_hex: $(HEX) + +all_assembly: $(ASM) + +$(ODIR)/%.hex: $(ODIR)/%.out + $(BIN2HEX) $< + +$(ODIR)/%.out: $(OBJ) + $(CC) $(CFLAGS)\ + -Wl,-Map -Wl,$(ODIR)/$(notdir $(basename $@)).map\ + -o $@ $^ + +$(ODIR)/%.o: %.c $(DEPS) + mkdir -p $(dir $@) + $(CC) $(CFLAGS) -c -o $@ $< + +$(ODIR)/%.s: %.c + mkdir -p $(dir $@) + $(CC) $(CFLAGS) -S -o $@ $< + +clean: + $(RM) -r $(ODIR) diff --git a/firmware/main.c b/firmware/main.c new file mode 100644 index 0000000..d85cfe1 --- /dev/null +++ b/firmware/main.c @@ -0,0 +1,52 @@ +#include <xc.h> +#include "t6963c_specific.h" +#include "t6963c/t6963c.h" + +// CONFIG1 +#pragma config WPCFG = WPCFGDIS // Write Protect Configuration Page Select->Last page (at the top of program memory) and Flash Configuration Words are not write-protected +#pragma config WPDIS = WPDIS // Segment Write Protection Disable->Segmented code protection is disabled +#pragma config WPFP = WPFP255 // Write Protection Flash Page Segment Boundary->Highest Page (same as page 170) +#pragma config SOSCSEL = EC // Secondary Oscillator Power Mode Select->External clock (SCLKI) or Digital I/O mode( +#pragma config ALTPMP = ALPMPDIS // Alternate PMP Pin Mapping->EPMP pins are in default location mode +#pragma config WPEND = WPENDMEM // Segment Write Protection End Page Select->Protected code segment upper boundary is at the last page of program memory; the lower boundary is the code page specified by WPFP +#pragma config WUTSEL = LEG // Voltage Regulator Wake-up Time Select->Default regulator start-up time is used + +// CONFIG2 +#pragma config POSCMOD = NONE // Primary Oscillator Select->Primary oscillator is disabled +#pragma config FCKSM = CSDCMD // Clock Switching and Fail-Safe Clock Monitor->Clock switching and Fail-Safe Clock Monitor are disabled +#pragma config OSCIOFNC = ON // OSCO Pin Configuration->OSCO/CLKO/RC15 functions as port I/O (RC15) +#pragma config PLL96MHZ = ON // 96MHz PLL Startup Select->96 MHz PLL is enabled automatically on start-up +#pragma config PLLDIV = NODIV // 96 MHz PLL Prescaler Select->Oscillator input is used directly (4 MHz input) +#pragma config IOL1WAY = ON // IOLOCK One-Way Set Enable->The IOLOCK bit (OSCCON<6>) can be set once, provided the unlock sequence has been completed. Once set, the Peripheral Pin Select registers cannot be written to a second time. +#pragma config FNOSC = FRCPLL // Initial Oscillator Select->Fast RC Oscillator with Postscaler and PLL module (FRCPLL) +#pragma config IESO = ON // Internal External Switchover->IESO mode (Two-Speed Start-up) is enabled + +// CONFIG1 +#pragma config WDTPS = PS32768 // Watchdog Timer Postscaler->1:32,768 +#pragma config GCP = OFF // General Segment Code Protect->Code protection is disabled +#pragma config FWDTEN = OFF // Watchdog Timer->Watchdog Timer is disabled +#pragma config ICS = PGx1 // Emulator Pin Placement Select bits->Emulator functions are shared with PGEC1/PGED1 +#pragma config WINDIS = OFF // Windowed WDT->Standard Watchdog Timer enabled,(Windowed-mode is disabled) +#pragma config JTAGEN = OFF // JTAG Port Enable->JTAG port is disabled +#pragma config FWPSA = PR128 // WDT Prescaler->Prescaler ratio of 1:128 +#pragma config GWRP = OFF // General Segment Write Protect->Writes to program memory are allowed + +void init(void) { + // CPDIV 1:1; RCDIV FRC/2; DOZE 1:8; G1CLKSEL disabled; DOZEN disabled; ROI disabled; + CLKDIV = 0x3100; + // GCLKDIV 1; + CLKDIV2 = 0x0000; + + t6963c_init(); +} + +int main(void) { + TRISBbits.TRISB0 = 0; + while (1) { + delay_ns(1000); + LATBbits.LATB0 = 0; + delay_ns(100); + LATBbits.LATB0 = 1; + } + return 0; +} diff --git a/firmware/t6963c b/firmware/t6963c new file mode 160000 +Subproject b228b23ce92f390d717c80d3e8331dc15727094 diff --git a/firmware/t6963c_specific.c b/firmware/t6963c_specific.c new file mode 100644 index 0000000..05b7ebf --- /dev/null +++ b/firmware/t6963c_specific.c @@ -0,0 +1,38 @@ +/** + * C library for interfacing a T6963C display with a PIC microcontroller + * Copyright (C) 2015 Camil Staps <info@camilstaps.nl> + + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <xc.h> +#include "t6963c_specific.h" + +inline void t6963c_initTimer(void) { +} + +inline void t6963c_startTimer(void) { + T2CON = 0xa000; // TMR2 enabled, 16-bit mode; gated time acc. disabled + PR2 = 0xffff; // ??? + TMR2 = 0x00; +} + +inline unsigned short t6963c_getTimeNs(void) { + return TMR2 * t6963c_nspertick; +} + +inline void t6963c_stopTimer(void) { + T2CON = 0x0000; +} diff --git a/firmware/t6963c_specific.h b/firmware/t6963c_specific.h new file mode 100644 index 0000000..4df7923 --- /dev/null +++ b/firmware/t6963c_specific.h @@ -0,0 +1,68 @@ +/** + * C library for interfacing a T6963C display with a PIC microcontroller + * Copyright (C) 2015 Camil Staps <info@camilstaps.nl> + + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + ******************************************************************************* + * + * File: t6963c_specific.h + * Author: Camil Staps + * + * Example of what you could put in a t6963c_specific.h. + */ + +#ifndef T6963C_SPECIFIC_H +#define T6963C_SPECIFIC_H + +#include <xc.h> + +#define t6963c_rst(x) LATFbits.LATF3 = (x) // RESET line +#define t6963c_cd(x) LATBbits.LATB6 = (x) // C/D line +#define t6963c_ce(x) LATBbits.LATB7 = (x) // CE line +#define t6963c_rd(x) LATFbits.LATF4 = (x) // RD line +#define t6963c_wr(x) LATFbits.LATF5 = (x) // WR line +#define t6963c_t_rst(x) TRISFbits.TRISF3 = (x) // TRIS bit of RESET pin +#define t6963c_t_cd(x) TRISBbits.TRISB6 = (x) // TRIS bit of C/D pin +#define t6963c_t_ce(x) TRISBbits.TRISB7 = (x) // TRIS bit of CE pin +#define t6963c_t_rd(x) TRISFbits.TRISF4 = (x) // TRIS bit of RD pin +#define t6963c_t_wr(x) TRISFbits.TRISF5 = (x) // TRIS bit of WR pin +#define t6963c_data(x) LATB = (LATB & 0x00ff) | (x << 8) // Data port +#define t6963c_t_data(x) TRISB = (TRISB & 0x00ff) | (x << 8) // TRIS register of data port + +#define t6963c_rows 16 // Number of rows of the LCD +#define t6963c_columns 40 // Number of columns of the LCD + +#ifdef __cplusplus +extern "C" { +#endif + +#define t6963c_nspertick 4000 + +/** + * Define the project-specific timer functions here + * @see t6963c.h + */ +inline void t6963c_initTimer(void); +inline void t6963c_startTimer(void); +inline unsigned short t6963c_getTimeNs(void); +inline void t6963c_stopTimer(void); + +#ifdef __cplusplus +} +#endif + +#endif /* T6963C_SPECIFIC_H */ + |