Device 16F870
Xtal = 4
All_Digital = true
Reminders false
Config DEBUG_OFF, LVP_OFF, PWRTE_OFF, WDT_OFF, HS_OSC
Reminders true
Declare RC5In_Pin = PORTA.4
Input PORTA
Output PORTB
Output PORTC
Symbol IN1_LED = PORTB.0
Symbol IN2_LED = PORTB.1
Symbol IN3_LED = PORTB.2
Symbol IN4_LED = PORTB.3
Symbol IN5_LED = PORTB.4
Symbol IN6_LED = PORTB.5
Symbol REC_LED = PORTB.6
Symbol REC1_LED = PORTC.0
Symbol REC2_LED = PORTC.1
Symbol REC3_LED = PORTC.2
Symbol REC4_LED = PORTC.3
Symbol REC5_LED = PORTC.4
Symbol REC_btn = PORTA.3
Dim RC5_rcv As Word
Dim RC5_device As RC5_rcv.HighByte
Dim RC5_command As RC5_rcv.LowByte
Dim Keys As Byte
Dim Key_mask As %00000111
Dim CMask As %11100000
Dim InButtons As Byte
Dim RecButton As Bit
Dim RecStatus As Bit
' setting initial states of output pins on power up
PORTB = %00000001 ' CH1 initially selected
PORTC = 0
Clear RecStatus
' Main program loop
While 1 = 1
GoSub CheckButtons
If REC_btn = 1 And RecStatus = 0 Then
High REC_LED
DelayMS 50 'debouncing of REC pb
Set RecStatus
While REC_btn = 1
DelayMS 10
Wend
GoSub CheckButtonsRec
Else
Low REC_LED
DelayMS 50 'debouncing of REC pb
Clear RecStatus
PORTC = 0 & CMask
End If
Wend
End
'****************************************************************
' * SUBs *
'****************************************************************
CheckButtons:
InButtons = PORTA
InButtons = ~(InButtons & Key_mask)
Select InButtons
Case 0
PORTB = %00000001
Case 1
PORTB = %00000010
Case 2
PORTB = %00000100
Case 3
PORTB = %00001000
Case 4
PORTB = %00010000
Case 5
PORTB = %00100000
End Select
' RecButton = REC_btn
' If RecButton = 1 Then
' Toggle REC_LED
' End If
Return
'****************************************************************
CheckButtonsRec:
InButtons = PORTA
InButtons = ~(InButtons & Key_mask)
Select InButtons
Case 0
PORTC = %00000001 & CMask
Case 1
PORTC = %00000010 & CMask
Case 2
PORTC = %00000100 & CMask
Case 3
PORTC = %00001000 & CMask
Case 4
PORTC = %00010000 & CMask
End Select
Return
Yes the test code you programmed in to PIC16F870 will flash the (record) light continuously at a rate of two flashes per seconds.I cant as there is no space and the tracks are very fragile and already badly damaged!!
But........Its alive!!!!!! The mute LED is on and the REC LED 7 is constantly flashing!
--- Updated ---
Was the REC LED suppose to constantly blink or for 2 seconds?
The same way you built it the first time.What do I do with these files?
I have copied the Main.c into the same folder as 16F870_AVI_S21_MI.X and over wrote the old file. How do I build the HEX file now please?
I am glad you are pleased with the firmware.After testing I can confirm the code works perfectly! Monumental achievement to be fair. Those involved know it just wouldn't have been possible without them so thank you for getting involved and sharing your wisdom. Much appreciated!
Some PIC's can be programmed to be impossible to reuse, try buying a new one off ebay, or some other dealer.Hi,
I have a faulty chip that I cannot read and am trying to programme a new one for replacement. The chip is pic16f870 and it came from an amplifier. I have gone through great difficulty just to get the device to read the chip in MPLAB IDE.
I have attached the schematic of the circuit with the chip I need to programme. Any help would be greatly apprectaited as currently the amplifier does nothing as the chip is dead. Believe to be electrostatically shocked in circuit. Thank you
The original poster(OP) had a different problem. The microcontroller on his front panel had failed. Why it failed has not been mentioned.Some PIC's can be programmed to be impossible to reuse, try buying a new one off ebay, or some other dealer.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?