// pulser lab for CSCI 255

// CSCI 255 clock configuration
#define CSCI255CLOCK FRCPLL80MZ
#include "csci255setup.h"
#pragma config FWDTEN=OFF      // Watch dog timer disabled

// Standard includes
#include <stdlib.h>
#include <stdint.h>

// PIC includes
#include <xc.h>
#include <libpic30.h>

// Output pin
// Pin 15 on PIC24HJ64GP502  --  PGEC3 / ASCL1 / RP6 / CN24 / PMD6 / RB6
#define PULSERTRIS   _TRISB6
#define PULSERVALUE  _LATB6

const int16_t pulseMS  =  800 ;
const int16_t periodMS = 1000 ;

int main() {
   setupClock() ;
   setupAllDigitalOutputWritingZero() ;

   PULSERTRIS  = 0 ;
   PULSERVALUE = 1 ;

   while (1) {
      PULSERVALUE = 1 ;
      __delay_ms(pulseMS) ;
      PULSERVALUE = 0 ;
      __delay_ms(periodMS-pulseMS) ;
   }

   return (EXIT_SUCCESS) ;
}

