~joshrig/mipsfoo

8a976f5ead372cb5b071032c8e937b84c769defb — Joshua Lynch 1 year, 30 days ago 926d1fa
bare metal blinky busy loop in action
2 files changed, 120 insertions(+), 0 deletions(-)

A config.c
A main.S
A config.c => config.c +66 -0
@@ 0,0 1,66 @@
#include <xc.h>
#include <sys/attribs.h>

#define DEVICE_NAME		 "PIC32MZ2048EFH064"
#define DEVICE_ARCH		 "MIPS"
#define DEVICE_FAMILY		 "PIC32MZEF"
#define DEVICE_SERIES		 "PIC32MZ"

/* CPU clock frequency */
#define CPU_CLOCK_FREQUENCY 200000000

/*** DEVCFG0 ***/
#pragma config DEBUG =      OFF
#pragma config JTAGEN =     OFF
#pragma config ICESEL =     ICS_PGx2
#pragma config TRCEN =      OFF
#pragma config BOOTISA =    MIPS32
#pragma config FECCCON =    OFF_UNLOCKED
#pragma config FSLEEP =     OFF
#pragma config DBGPER =     PG_ALL
#pragma config SMCLR =      MCLR_NORM
#pragma config SOSCGAIN =   GAIN_LEVEL_3
#pragma config SOSCBOOST =  ON
#pragma config POSCGAIN =   GAIN_LEVEL_3
#pragma config POSCBOOST =  ON
#pragma config EJTAGBEN =   NORMAL
#pragma config CP =         OFF

/*** DEVCFG1 ***/
#pragma config FNOSC =      SPLL
#pragma config DMTINTV =    WIN_127_128
#pragma config FSOSCEN =    OFF
#pragma config IESO =       OFF
#pragma config POSCMOD =    OFF
#pragma config OSCIOFNC =   OFF
#pragma config FCKSM =      CSECME
#pragma config WDTPS =      PS1048576
#pragma config WDTSPGM =    STOP
#pragma config FWDTEN =     OFF
#pragma config WINDIS =     NORMAL
#pragma config FWDTWINSZ =  WINSZ_25
#pragma config DMTCNT =     DMT31
#pragma config FDMTEN =     OFF

/*** DEVCFG2 ***/
#pragma config FPLLIDIV =   DIV_1
#pragma config FPLLRNG =    RANGE_5_10_MHZ
#pragma config FPLLICLK =   PLL_FRC
#pragma config FPLLMULT =   MUL_50
#pragma config FPLLODIV =   DIV_2
#pragma config UPLLFSEL =   FREQ_24MHZ

/*** DEVCFG3 ***/
#pragma config USERID =     0xffff
#pragma config FMIIEN =     ON
#pragma config FETHIO =     ON
#pragma config PGL1WAY =    ON
#pragma config PMDL1WAY =   ON
#pragma config IOL1WAY =    ON
#pragma config FUSBIDIO =   ON

/*** BF1SEQ0 ***/

#pragma config TSEQ =       0xffff
#pragma config CSEQ =       0x0


A main.S => main.S +54 -0
@@ 0,0 1,54 @@
#include <xc.h>
        
        .set nomips16
        .set nomicromips
        .set noreorder

        .align 2

        .section .reset,code,keep

        .ent _reset
_reset:
        di                      // disable interrupts
        ehb                     // hazard barrier

        la  t1, 0xBF860130      // LATB
        sw  zero, (t1)          // enable gpio port

        li  t3, 0x7
        sll t3, t3, 8           // gpio mask

        la  t1, 0xBF860114      // TRISBCLR
        sw  t3, (t1)            // set output pin direction

        la  t1, 0xBF860104      // ANSELCLR
        sw  t3, (t1)            // enable digital mode

        li  t7, 4000000

        li  t0, 0               // load the initial counter value
        la  t4, 0xBF860134      // LATBCLR
        la  t5, 0xBF860138      // LATBSET

1:
        sw    t3, (t4)          // logic low on the gpios

        addiu t0, t0, 1         // increment t0, save to t1
        and   t1, t0, 0x7       // mask off the relevant gpios
        sll   t1, t1, 8         // left shift the values
        sw    t1, (t5)          // set the gpios high

        move  t6, t7            // load delay
loop:
        subu t6, t6, 1          // subtract 1
        bnez t6, loop           // if t6 != 0, loop
        nop

        j 1b
        nop

        .end _reset
        .globl _reset
        .size _reset, .-_reset