this is code i have begun to write for what will be a learning robot
controlled by the pic18f452, the code complies and is written to the pic
without major trouble but when i insert it to the robot there is no outputs
as if the pic isnt reading anything, i think i may have a configuration
problem but i cant see anything obviously wrong, does see anything that may
help?
#include <stdio.h>
#include <math.h>
#include "pic16/pic18f452.h"

code char at __CONFIG1H config1h = 0xFF;
code char at __CONFIG2L config2l = 0xFD;
code char at __CONFIG2H config2h = 0x00;
code char at __CONFIG3H config3h = 0xFF;
code char at __CONFIG4L config4l = 0xFB;
code char at __CONFIG5L config5l = 0xFF;
code char at __CONFIG5H config5h = 0xFF;
code char at __CONFIG6L config6l = 0xFF;
code char at __CONFIG6H config6h = 0xFF;
code char at __CONFIG7L config7l = 0xFF;
code char at __CONFIG7H config7h = 0xFF;
void main() {
int PWL=0;
int PWR=0;
PORTA=0x00;
TRISA=0x7F;
PORTB=0x00;
TRISB=0x00;
PORTC=0x00;
TRISC=0x00;
PORTD=0x00;
TRISD=0x00;
PORTE=0x00;
TRISE=0x00;
// KILL WATCHDOG
WDTCON=0x00;
//SET EXT CLOCK
OSCCON=0x00;
// INTERUPT ENABLE
INTCON=0xD4;
//PWM SETUP
PR2=0xFA;
CCPR1L=PWL;
CCPR2L=PWR;

INTCONbits.T0IE=0;

T2CONbits.T2CKPS1=1;
T2CONbits.TMR2ON=1;

CCP1CONbits.CCP1M2=1;
CCP1CONbits.CCP1M3=1;
CCP1CONbits.DCCP1Y=0;
CCP1CONbits.DCCP1X=0;
CCP2CONbits.CCP2M2=1;
CCP2CONbits.CCP2M3=1;
CCP2CONbits.DCCP2Y=0;
CCP2CONbits.DCCP2X=0;

// MAIN PROGRAM
for(;;) {
   PWL=0x7D;
   PWR=0x7D;
if (PORTAbits.RA0==0)
   {T0CON=0x87;
     while(INTCONbits.T0IF==0) { PORTCbits.RC2=1; PORTCbits.RC3=1;
PWR=0xA3; PWL=0x43;}
         T0CON=0x00; INTCONbits.T0IF==0;}
if (PORTAbits.RA1==0)
   {T0CON=0x87;
     while(INTCONbits.T0IF==0)     {PORTCbits.RC2=1; PORTCbits.RC3=1;
PWR=0x43; PWL=0xA3;}
        T0CON=0x00; INTCONbits.T0IF==0;}
if (PORTAbits.RA2==0)
   {T0CON=0x87;
     while(INTCONbits.T0IF==0)     {PORTCbits.RC2=0; PORTCbits.RC3=0;
PWR=0x43; PWL=0xA3;}
       T0CON=0x00; INTCONbits.T0IF==0;}
   }
   CCPR1L=PWL;
   CCPR2L=PWR;
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to