Jump to content

DanW

Members
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral

About DanW

  • Rank
    Newbrie
  1. I'm new to boostc and saw a pic article about using the ADC's as analog touch sensors. http://ww1.microchip...otes/01298A.pdf I've been trying for a couple of days without some success but both channels are getting detected with same value when either button is pressed. Here's what I did: adcon0 = 00000001b; // Turn on the A/D converter, select channel 0 . delay_ms(20); Go_Done=1; // Start conversion while ( Go_Done == 1 ) // Wait for conversion to complete -- better put a timeout in here some time. { } // Separate int's need to be used to keep the shifts from screwing up. shiftH = ad_h; shiftL = ad_l; AD_Result2 = (shiftH<<2) | (shiftL>>6); // Combine the two registers to get full 10 bits. adcon0 = 00000101b; // Turn on the A/D converter, select channel 1 . delay_ms(20); Go_Done=1; // Start conversion while ( Go_Done == 1 ) // Wait for conversion to complete -- better put a timeout in here some time. { } // Separate int's need to be used to keep the shifts from screwing up. shiftH = ad_h; shiftL = ad_l; AD_Result3 = (shiftH<<2) | (shiftL>>6); // Combine the two registers to get full 10 bits. if (AD_Result2 > 500 || AD_Result3 > 500) { //code to output both values goes here } The problem I see is when I hit button 1, both AN0 and AN1 register as input. The microchip doc says I need to set a dummy AN port to VDD and then GND. Has anyone ever done this? Thanks Dan.
  2. Yes, if I write a 0x18 I read back 1 second later a 0x10. I have tried two 16f877's with same results. I do have a theory now... I think both 16f877's have been damaged. I wrote small program to toggle each portb pin. For both 877's I saw every pin toggle except RB3. I sent the hex file to someone who could test the hex file on another 877. The hex file worked for them and not for me. I am going to order a few more 877's, test them outside my pcb, and then if they are ok, try one in the circuit. If it fails, it may be because I am drawing too much current on portb and killing the chips. I will reply here with the result in about a week. Dan.
  3. I have a PIC 16F877 which I have programmed to control another device. I have portb configured as an output and provides the address to this other device. When I write 0x18,0x19 or any byte having the the 4th bit set it always returns a zero 0. (Not always. Occasionally, it will return correctly, but just once) So if I write 0x18 I get back 0x10. If I write 0x19, I get back 0x11. I see in the 877 PDF that this pin can also be assigned to a low voltage programming function, but I have the option disabled in the configuration bits. I've tried two boards, and also tried sending the byte without the address lines connected to the destination device, but always the same result. I've tried two 16F877 devices with the same results. Dan.
  4. I was wondering why this didn't work... char accessAddress@realAddress; int address = realAddress; sendString("Displaying address: "); sendHex(realAddress); sendString("\r\n"); char addressHigh = (address & 0xFF00) >> 8; char addressLow = (address & 0x00FF); sendString("Address: "); sendString("0x"); sendHex(addressHigh); sendHex(addressLow); sendString(" - "); sendString("0x"); sendHex(accessAddress); sendString(" \r\n");
×
×
  • Create New...