>
>
>>
>> Well, I initialized ANSEL and CMCON according to the whole init() method
>> in
>> one of the replies, but that didn't quite do it. Now the LEDs turn off
>> after ramping on. I've hooked up an independent LED to each of the pins
>> to
>> better visualize what it's doing, and here's a stepwise program
>> execution:
>> led1 fades on, then shuts off. led2 fades on, then shuts off. led3
>> fades
>> on, but then STAYS on. LED1 switches on, then fades off, and stays off.
>> then LED2. then LED3, which is still on, fades off. So it seems like
>> having a different LED fade on after another will cause the first to shut
>> off, because the third one operates exactly as I wish they all would.
>> So...perhaps it's in the code? I'm coming to C from java, which sort of
>> feels like switching to the flintstone mobile after a cadillac.
>>
>> Here's the code as it is now (ignore the checkfinger stuff...I'm going to
>> try to implement a capacitive touch-sensing switch).
>>
>> Eli
>
> I'm guessing WDT timeout or osc config problem.
>
> Try embedding config options in your source.
>
> __CONFIG ( UNPROTECT & WDTDIS & BOREN & PWRTEN & MCLRDIS & INTIO);
>
> I ran your example with 3 LEDs, and it works as advertised. Fades on/off,
> recycles, etc,.
> See attached.
>
> Regards,
>
> -Bruce
>
>
tech
KILLspamrentron.com
> Reynolds Electronics
>
> #include <htc.h>
> #define pin1 GPIO0
> #define pin2 GPIO1
> #define pin3 GPIO2
>
> __CONFIG ( UNPROTECT & WDTDIS & BOREN & PWRTEN & MCLRDIS & INTIO);
>
> void rampoff(int time, int purpose);
> void rampon(int time, int purpose);
> void delay(int msec);
> void checkFinger(void);
> void init(void);
>
>
> int i;
> int contShifting;
>
> void main(void){
> init();
>
> contShifting = 1;
>
> while(1){
> // checkFinger(void);
>
> delay(1000);
>
> rampon(60, 1);
> rampon(60, 2);
> rampon(60, 3);
> rampoff(60, 1);
> rampoff(60, 2);
> rampoff(60, 3);
>
>
> delay(1000);
> }
>
>
> }
>
> void checkFinger(void){
> GPIO3 = 1;
>
> }
>
>
>
>
> void rampon(int time, int purpose){
> if (purpose == 1){
> int x;
> int rampcounter1;
> for (rampcounter1 = 0; rampcounter1 < 40; rampcounter1++){
> for (x = 0; x < time; x++){
> pin1 = 0;
> delay(40 - rampcounter1);
> pin1 = 1;
> delay(rampcounter1);
> }
> }
> }
>
> else if (purpose == 2){
> int y;
> int rampcounter2;
> for (rampcounter2 = 0; rampcounter2 < 40; rampcounter2++){
> for (y = 0; y < time; y++){
> pin2 = 0;
> delay(40 - rampcounter2);
> pin2 = 1;
> delay(rampcounter2);
> }
>
> }
> }
>
> else if (purpose == 3){
> int z;
> int rampcounter3;
> for (rampcounter3 = 0; rampcounter3 < 40; rampcounter3++){
> for (z = 0; z < time; z++){
> pin3 = 0;
> delay(40 - rampcounter3);
> pin3 = 1;
> delay(rampcounter3);
> }
>
> }
> }
> }
> void rampoff(int time, int purpose){
> if (purpose == 1){
> int a;
> int rampcounter4;
> for (rampcounter4 = 0; rampcounter4 < 40; rampcounter4++){
> for (a = 0; a < time; a++){
> pin1 = 1;
> delay(40 - rampcounter4);
> pin1 = 0;
> delay(rampcounter4);
>
> }
>
> }
> }
>
> else if (purpose == 2){
> int b;
> int rampcounter5;
> for (rampcounter5 = 0; rampcounter5 < 40; rampcounter5++){
> for (b = 0; b < time; b++){
> pin2 = 1;
> delay(40 - rampcounter5);
> pin2 = 0;
> delay(rampcounter5);
> }
>
> }
> }
>
> else if (purpose == 3){
> int c;
> int rampcounter6;
> for (rampcounter6 = 0; rampcounter6 < 40; rampcounter6++){
> for (c = 0; c < time; c++){
> pin3 = 1;
> delay(40 - rampcounter6);
> pin3 = 0;
> delay(rampcounter6);
> }
>
> }
> }
> }
>
>
> void delay(int msec){
>
> for (i = 0; i < msec; i++){
> NOP();
> }
> }
>
> void init(void){
> /*
> * set all pins to real, program controlled outputs
> */
> ANSEL = 0x0;
> VRCON = 0; //Turn Off Voltage Reference Peripheral
> CMCON = 0x07; //Turn Off Comparator Peripheral
> TMR0 = 0; //Clear Timer0
> INTCON = 0;
> OPTION = 0x80;
> TRISIO = 0x00;
> GPIO = 0;
> }
>
>