Dr_Doggy
Well-Known Member
all defined leds are just for that, LED indicators this is my first time defining anything, how was that, is there better way to simplify? I would have liked to do this: #define LEDx PORTxbits.Rxx; (IN main): LEDx = 1; but mplab didnt like that.
anyway im more concerned with the if statement down there, as you can see there are 4 ports tied to buttons that hit a breakpoint when cnt++; however on my tests ports b0,a2,a3 are working ok, and like the other ports a1 is also on a button that goes to 0 when pressed. Also i have been testing port a0 in the if statement which is actually on a pot but is also never going to logic1 just like port a1. I disabled adc.h to ensure that it was not a conflict there, but still no results... and i have tested on leg of a1 with near 5v and have replaced microchip.... im sure this is rookie mistake....
.....also i seen recent questions on demoboards, i do it this way so then i dont need to plan for icsp bus, and can eject the chip for programming(when icsp clk/dat debugging conflict with the port data(not in this case today))...... just my idea of simplicity!
anyway im more concerned with the if statement down there, as you can see there are 4 ports tied to buttons that hit a breakpoint when cnt++; however on my tests ports b0,a2,a3 are working ok, and like the other ports a1 is also on a button that goes to 0 when pressed. Also i have been testing port a0 in the if statement which is actually on a pot but is also never going to logic1 just like port a1. I disabled adc.h to ensure that it was not a conflict there, but still no results... and i have tested on leg of a1 with near 5v and have replaced microchip.... im sure this is rookie mistake....
Code:
#pragma config OSC=INTIO2, WDT=OFF
///#include <adc.h>
#include <p18f1230.h>
#include <string.h>
#include <delays.h>
#define LED1o LATAbits.LATA4 = 1;#define LED2o LATBbits.LATB3 = 1;
#define LED3o LATBbits.LATB2 = 1;#define LED4o LATAbits.LATA7 = 1;
#define LED5o LATAbits.LATA6 = 1;#define LED6o LATBbits.LATB7 = 1;
#define LED7o LATBbits.LATB6 = 1;#define LED8o LATBbits.LATB5 = 1;
#define LED1f LATAbits.LATA4 = 0;#define LED2f LATBbits.LATB3 = 0;
#define LED3f LATBbits.LATB2 = 0;#define LED4f LATAbits.LATA7 = 0;
#define LED5f LATAbits.LATA6 = 0;#define LED6f LATBbits.LATB7 = 0;
#define LED7f LATBbits.LATB6 = 0;#define LED8f LATBbits.LATB5 = 0;
//unsigned int READPOT ();
void main(){
unsigned char cnt;
unsigned char cnt4;
unsigned int xxx;
unsigned int xxx2;
OSCCON= 0b01110000; //8MHz please
OSCTUNE=0b00011100;
CMCON=0x00;
TRISA = 0b00101111;
TRISB = 0b00000001;
cnt = 0;
while(1) {
if ((PORTBbits.RB0 == 0) || (PORTAbits.RA1 == 0) || (PORTAbits.RA2 == 0) || (PORTAbits.RA3 == 0)){
cnt++;
}
switch(cnt){
case 1: LED1o;LED8f;break;case 2: LED2o;LED1f;break;
case 3: LED3o;LED2f;break;case 4: LED4o;LED3f;break;
case 5: LED5o;LED4f;break;case 6: LED6o;LED5f;break;
case 7: LED7o;LED6f;break;case 8: LED8o;LED7f;break;
}
Delay10KTCYx(200);
}
}
.....also i seen recent questions on demoboards, i do it this way so then i dont need to plan for icsp bus, and can eject the chip for programming(when icsp clk/dat debugging conflict with the port data(not in this case today))...... just my idea of simplicity!