T
treez
Guest
Hello,
I am writing XC8 (free version) C for PIC18F65K22 in MPLAB.X environment.
I wish to define an 8 bit register, which I am calling “dip8”.
I also wish to refer to each bit of this register.
How do I do this in C?
Do I have to use inline assembler.
Here is how I declare the variable…
Unsigned int dip8;
Here is my code so far
I am writing XC8 (free version) C for PIC18F65K22 in MPLAB.X environment.
I wish to define an 8 bit register, which I am calling “dip8”.
I also wish to refer to each bit of this register.
How do I do this in C?
Do I have to use inline assembler.
Here is how I declare the variable…
Unsigned int dip8;
Here is my code so far
* File: 3CH TEST.c
*
* Created on 24 October 2014, 21:33
*/
/*DEFINE OUTPUTS*/
#define ch1bit LATE,LATE1
#define ch2bit LATE,LATE0
#define ch3bit LATG,LATG0
#define ind_ledbit LATC,LATC2
#define fanconbit LATE,LATE2
#define tripbit LATA,LATA4
#define mcp4013_csbit LATC,LATC3
#define mcp4013_udbit LATC,LATC4
/* TURN LEDS ON AND OFF*/
#define ON1 LATE,LATE1 = 1; /*Turn on chan1*/
#define OFF1 LATE,LATE1 = 0; /*Turn off chan1*/
#define ON2 LATE,LATE0 = 1; /*Turn on chan2*/
#define OFF2 LATE,LATE0 = 0; /*Turn off chan2*/
#define ON3 LATG,LATG0 = 1; /*Turn on chan2*/
#define OFF3 LATG,LATG0 = 0; /*Turn off chan2*/
#define FANON LATE,LATE2 = 1; /*Turn fan on*/
#define FANOFF LATE,LATE2 = 0; /*Turn fan off*/
/*DEFINE INPUTS FROM DIPSWITCH*/
/*Note that the new board has pullups on the dipswitch,*/
/*whereas 550587 PCB had pull downs, thus logic is reversed.*/
#define modebit dip8,0 /*low = external connector sets power via 0-10V*/
#define LSBbit dip8,1 /*00 -> 3.52A, 01 -> 2.64A, 10 -> 1.76A, 11 -> OFF*/
#define MSBbit dip8,2
#define polaritybit dip8,3 /*high = 10V gives max current*/
#define t80t90bit dip8,4 /*high = 80degC, low=90degC*/
#define fanbit dip8,8 /*high = fan fitted, low = no fan fitted*/
/*DEFINE INPUTS FROM EXTERNAL CONNECTOR*/
#define re_setbit ext_in,0
#define ch1_extbit ext_in,1
#define ch2_extbit ext_in,2
#define ch3_extbit ext_in,3
#define clearbit ext_in,4
unsigned int dip8;
unsigned int ext_in;
#include <xc.h>
/*
*
*/
void main(void) {
return ();
}