I absolutely do not care about what statement it will be.
I'm asking why it does not works, whenever it is HIGH/LOW or TRIS.
I absolutely do not care about what statement it will be.
I'm asking why it does not works, whenever it is HIGH/LOW or TRIS.
OK. Lets stick on your first code that looks OK to me.
What is connected to your buzzer output? Can you connect only a LED with a resistor for testing purposes?
And I would also consider having decoupling capacitors the power rails, as close as possible to the PIC power pins.
Maybe you have an interference of the buzzer if it is electromagnetic?
Ioannis
Hey CuriousOne, Where is the ENDIF to finish the "if BUTN=0 then" statement?
Dave Purola,
N8NTA
EN82fn
Assuming we refer to the first program, the ENDIF it there at the end.
On the snippets it is missing, but I doubt that this can compile anyway.
Ioannis
I don't use this particular Model T PIC, so I reserve the right to miss some quirks. Here are things I would check:
1. You don't list your CONFIGs, but try disabling the WDT. It could be resetting on you.
2. Try enabling CLKOUT and verify oscillator. On one project I did years ago, I had the crystal too far from the OSC pins and it would work for a few seconds then Peter out.
3. Not sure which PORT PIN is MCLR, but you only have one Input in your TRISx Registers. MCLR should be a "1" (even though it probably defaults to Input Only). Don't forget the pull-up resistor.
4. Make sure there are no other default settings triggering things unexpectedly (like Comparator or something).
5. I think you already tried removing the PICkit3 programmer before trying the code. Using PORTB.7 probably ties into a PICkit3 programming pin.
Some food for thought, things to try. Hope it helps.
Code:#CONFIG cfg1 = _INTRC_OSC_NOCLKOUT ; INTOSCIO oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN cfg1&= _WDT_ON ; WDT enabled cfg1&= _PWRTE_OFF ; PWRT disabled cfg1&= _MCLRE_OFF ; RE3/MCLR pin function is digital input, MCLR internally tied to VDD cfg1&= _CP_OFF ; Program memory code protection is disabled cfg1&= _CPD_OFF ; Data memory code protection is disabled cfg1&= _BOR_OFF ; BOR disabled cfg1&= _IESO_ON ; Internal/External Switchover mode is enabled cfg1&= _FCMEN_ON ; Fail-Safe Clock Monitor is enabled cfg1&= _LVP_OFF ; RB3 pin has digital I/O, HV on MCLR must be used for programming cfg1&= _DEBUG_OFF ; In-Circuit Debugger disabled, RB6/ICSPCLK and RB7/ICSPDAT are general purpose I/O pins __CONFIG _CONFIG1, cfg1 cfg2 = _BOR40V ; Brown-out Reset set to 4.0V cfg2&= _WRT_OFF ; Write protection off __CONFIG _CONFIG2, cfg2
Ok here are answers.
1. PORTB.7 is connected via 10K resistor to MPSA42 transistor, which drives buzzer.
2. I tried replacing it with led, different buzzer, no difference. Sometimes it works, sometimes it does not.
3. I've used another PIC16F887 - no change.
4. Of course I've tried disconnecting pickit 3 - no difference.
5. This problem ONLY occurs with PORTB.7 as output and PORTA.0 as input. Say if I don't query PORTA.0 for input and just make PORTB.7 high/low from the code, it works fine.
6. All remaining ports (except PORTA 1 & 2 which are connected to DS3231) are connected via 10K resistors to MPSA42 transistors, which drive nixie tube cathodes and work fine.
7. MCLR, WDT and others are disabled, as you can see from above config.
Bookmarks