Fórum témák

» Több friss téma
Fórum » PIC kezdőknek
 
Témaindító: Placi84, idő: Okt 3, 2005
Témakörök:
- A PIC ÖSSZES Vdd és Vss (AVdd és AVss) (tápfeszültség) lábát be kell kötni!
- A táplábak mellé a lehető legközelebb 100nF-os KERÁMIA kondenzátorokat kell elhelyezni.
- Az MCLR lábat, 10kohm-mal fel kell húzni a Vdd tápfeszültségre.
- Külső kvarc használatakor 4MHz-ig XT, a fölött pedig HS konfigurációt kell beállítani.
- Stabilizált tápegységet kell használni, a kapcsoló üzemű "telefon töltő" adapterek okozhatnak hibákat.
- Programozáshoz, használj lehetőleg PICKIT2 vagy 3 programozót. Kerülendő a JDM (soros porti) programozó.
- A PIC adatlapja (PDF), tartalmazza a lábak kiosztását és a PIC minden paraméterét. Az adatlap ingyen letölthető!
- Egyes PIC típusoknál az RA4 nyitott nyelőelektródás (Csak lefelé húz L szintre, H szintet nem ad ki!)
- Ha a PGM lábat digitális ki-/bemenetnek használod, az alacsony feszültségű programozási lehetőséget le kell tiltani.
Lapozás: OK   1178 / 1203
(#) Baxi válasza Bakman hozzászólására (») Máj 21, 2022 /
 
Isten vagy, nagyon szépen köszönöm!
Nem értem Én ezt, múlt héten még vitte/látta ma meg már semmi. S mint írtam is újra telepítettem a pickit szoftverét is,és bemásoltam az újabb PK2DeviceFile.dat fájlt is. PC újraindítás stb, de semmi ugyanúgy nem látta.
Az állattad linkeltet bemásoltam, s láss csodát működik
(#) Naresh Jain hozzászólása Máj 27, 2022 /
 
Hi friends, I NEED YOUR HELP, I have fan controller circuit with diagram and codes using microcontroller PIC12F675, circuit works successfully on hardware,now I want to use PIC16F676 inplace of PIC12F675 and need to changes in codes for PIC16F676, schematic and source codes files attached here:
A hozzászólás módosítva: Máj 27, 2022
(#) Hp41C válasza Naresh Jain hozzászólására (») Máj 27, 2022 /
 
Hi,

Since 16F676 has PORTA/TRISA registers put some define lines into conditional blocks.
  1. #if defined _12F675
  2. __CONFIG(WDTDIS & MCLRDIS & INTIO & BORDIS & UNPROTECT & PWRTEN);
  3.  
  4. #define IsIRDataBitHigh()   GPIO3 == 0  // Inverted logic
  5. #define SW_UP           _GPIO,0         // Up switch
  6. #define SW_DN           _GPIO,2         // Down switch
  7. #define LEDOn()         GPIO1 = 1       // LED
  8. #define LEDOff()        GPIO1 = 0
  9. #define TriacOn()       GPIO5 = 0       // Triac
  10. #define TriacOff()      GPIObits.GPIO5 = 1
  11. #define TRIAC           GPIO5           // Triac pin
  12. #endif
  13.  
  14. #if defined _16F676
  15. __CONFIG(WDTDIS & MCLREN & INTOSCIO & BORDIS & UNPROTECT & PWRTEN);
  16.  
  17. #define GPIO PORTA
  18. #define TRISIO TRISA
  19. #define GPIF RAIF
  20. #define GPIE RAIE
  21.  
  22. #define IsIRDataBitHigh()   PORTAbits.RA3 == 0  // Inverted logic
  23. #define SW_UP           PORTA,0         // Up switch
  24. #define SW_DN           PORTA,2         // Down switch
  25. #define LEDOn()         PORTAbits.RA1 = 1       // LED
  26. #define LEDOff()        PORTAbits.RA1 = 0
  27. #define TriacOn()       PORTAbits.RA5 = 0       // Triac
  28. #define TriacOff()      PORTAbits.RA5 = 1
  29. #define TRIAC           PORTAbits.RA5           // Triac pin
  30. #endif
  31.  
  32. __IDLOC7('0','.','7','B');


The IC locations can be set out of conditional block
(#) Naresh Jain válasza Hp41C hozzászólására (») Máj 28, 2022 /
 
Dear sir, I don't know how to change in codes, I simply copy and paste the above said code but not success, I request you please make the changes in attached src file here :

src.rar
    
(#) Hp41C válasza Naresh Jain hozzászólására (») Máj 28, 2022 /
 
Modification made by replacing lines 37-44 in Your main.c with the lines uploaded.
It can be compiled with old MpLab 9.xx and XC8 1.3x.
(#) Naresh Jain válasza Hp41C hozzászólására (») Máj 28, 2022 /
 
Dear sir ,screen shot of 37-44 attached here,I replaced the marked codes with codes upload by you and compiled in xc8 1.33 but received error,error screen shot also attached,I think I made mistake:
A hozzászólás módosítva: Máj 28, 2022
(#) Hp41C válasza Naresh Jain hozzászólására (») Máj 28, 2022 /
 
My version of main.c could be compiled....
(#) pipi válasza Naresh Jain hozzászólására (») Máj 28, 2022 /
 
and remove spaces

sp.png
    
(#) Naresh Jain válasza Hp41C hozzászólására (») Máj 29, 2022 /
 
Thank you very much Mr. Hp41C and Mr. pipi for your support, I compiled the code successfully as you define, but I faced a problem ,I simulate the circuit in proteus of 12f675 with previous code successfully but the circuit with 16f676 with new genrated code not simulate in proteus,both proteus files,screen shot and hex attached here ;
A hozzászólás módosítva: Máj 29, 2022
(#) Hp41C válasza Naresh Jain hozzászólására (») Máj 29, 2022 /
 
In Your configuration settings for 12F625 conatins MCLRDIS but settings for 12F676 conatins MLCRLEN. Change it to MCLRDIS since RA3 is the output of IR receiver.
A hozzászólás módosítva: Máj 29, 2022
(#) Naresh Jain válasza Hp41C hozzászólására (») Máj 29, 2022 /
 
THANK YOU VERY MUCH Mr. Hp41C,
YOU ARE REALLY GENIUS,
This Platform is very good for learn, I really very appreciate,
Thanks Again.
(#) Naresh Jain válasza Hp41C hozzászólására (») Máj 29, 2022 /
 
Dear sir, I simulate the circuit with 16f676 successfully in proteus,
One more question please, can I test with ir remote in proteus, it has ir nec protocol, I have not ir nec transmitter in proteus,but I have Rc5 EasyHDL script generator,it can generate rc commands,easyhdl rc5 code attached,kindly make changes it for nec protocol;
  1. //  RC5ext1.scr, made by zuisti (Istvan K (c) copyright 2015)
  2.  
  3. // ext controlled RC5 code generator, one-shot or repeating, idle: HI
  4. // output = X[0], true toggle-bit handling, extended command using the bit #1
  5. // 1 start bit (1), 1 ext bit, 1 toggle bit, 5 addr bits, 6 cmd bits (sum 14)
  6.  
  7. PIN X[0..15] // 0 = out, 1 = rep, 2,3,4,5,6,7,8,9 = 8 buttons, 14 = ON/OFF
  8.  
  9. // data pairs for 8 buttons, max: 31,63 + 64 (0x1F,0x3F + 0x40 = 0x7F = 127)
  10. DATA 0,18
  11. DATA 0,1
  12. DATA 0,2
  13. DATA 0,3
  14. DATA 0,4
  15. DATA 0,5
  16. DATA 0,6
  17. DATA 0,30
  18. DATA 0,8
  19. DATA 0,9
  20. DATA 0,16
  21. DATA 0,17
  22. DATA 0,32
  23. DATA 0,33
  24.  
  25. // Define timings (RC5)
  26. FLOAT Bit_Time  = 1.778m
  27. FLOAT Half_Time = Bit_Time / 2
  28. FLOAT REP_Time  = 79m // 114ms - (14 * Bit_Time) - 10ms
  29.  
  30. // variables
  31. INT tgl  = 0 // but toggle after each NEW (even the same!) key pressed
  32. INT keym = %1111111111111100 // mask: all button (sw) is off
  33. INT code = 0 // until any send but after each send it's 1
  34. INT addr, cmd, cnt
  35.  
  36. // weak pullup for every input pin
  37. x[15] = WHI
  38. X[14] = WHI
  39. X[13] = WHI
  40. X[12] = WHI
  41. X[11] = WHI
  42. X[10] = WHI
  43. X[9] = WHI //sw7
  44. X[8] = WHI
  45. X[7] = WHI
  46. X[6] = WHI
  47. X[5] = WHI
  48. X[4] = WHI
  49. X[3] = WHI
  50. X[2] = WHI //sw0
  51. X[1] = WHI //rep jumper
  52. X[0] = SHI //out (idle)
  53.  
  54. // -------
  55.  
  56. MainLoop: // infinite loop begin
  57.  
  58.   SLEEP FOR 10m
  59.   // time for set/read the pins to avoid a false send (eg at begin)
  60.   // and leave time for the rest of the world
  61.  
  62.   cmd = X & keym // (re)read the button states, only once in the loop !
  63.   IF cmd <> keym THEN // if any button pressed
  64.  
  65.     GOSUB Rc5send // input: cmd
  66.     X[0] = SHI    // restore idle (need if the last bit was 0)
  67.  
  68.     // is repeat jumper closed ? (tgl remains the same while repeating)
  69.     IF (X & %10) = 0 THEN SLEEP FOR REP_Time : GOTO MainLoop
  70.      
  71.     // one-shot, waiting for (all) key release
  72.     loop1: SLEEP FOR 2m : IF (X & keym) <> keym THEN GOTO loop1
  73.    
  74.   ENDIF // pressed
  75.  
  76.   // new (even the same) keystroke ?
  77.   IF code THEN // Rc5send set it to 1
  78.      code = 0
  79.      tgl = tgl ^ 1 // toggle
  80.   ENDIF
  81.  
  82. GOTO MainLoop // infinite loop end
  83.  
  84. // ------- subroutines
  85.  
  86. Rc5send: // input: cmd
  87.  // to get the proper data position a computed restore is using
  88.  RESTORE
  89.  
  90.  // here cmd = X & keym : ie sw7...0 inputs in bit 9...2 (tested bit)
  91.  
  92.  FOR cnt = 0 TO 13   // search for the depressed button
  93.     IF (cmd & %100) = 0 THEN BREAK // found
  94.     READ addr, addr // skip (drop) one data pair
  95.     cmd = cmd >> 1  // shift next button pin value to bit 2
  96.  NEXT cnt
  97.  READ addr, cmd     // get the actual data pair to be send
  98.  
  99.  // ext Rc5 header, one start (1) bit: #1  
  100.  GOSUB sendbit1
  101.  
  102.  // the ext bit: #2
  103.  IF cmd < 64 THEN   // not extended
  104.     GOSUB sendbit1  // normal 2nd start bit
  105.  ELSE
  106.     GOSUB sendbit0
  107.     cmd = cmd & 63
  108.  ENDIF
  109.  
  110.  // toggle bit: #3, firstly 0, toggled (0 <> 1) after each new keypress
  111.  IF tgl THEN
  112.     GOSUB sendbit1
  113.  ELSE
  114.     GOSUB sendbit0
  115.  ENDIF
  116.  
  117.  // 5-bit address, bit #4 to #8
  118.  code = 0
  119.  GOSUB sendbyte
  120.  
  121.  // 6-bit command, bit #9 to #14
  122.  code = 1
  123.  addr = cmd
  124.  
  125. sendbyte: // input byte: addr, send MSB first
  126.   // drop bits 7 and 6, bit 5 will be tested
  127.   FOR cnt = 0 TO 5
  128.     // drop bit 5 of the address byte (code = 0 and cnt = 0)
  129.     IF code OR cnt THEN
  130.       IF (addr & %100000)
  131.         GOSUB sendbit1
  132.       ELSE
  133.         GOSUB sendbit0
  134.       ENDIF
  135.     ENDIF
  136.     addr = addr << 1 // shift next bit to the bit 5 (testing) position
  137.   NEXT cnt
  138. RETURN
  139.  
  140. sendbit0:
  141.   X[0] = SLO
  142.   SLEEP FOR Half_Time
  143.   X[0] = SHI
  144.   SLEEP FOR Half_Time
  145. RETURN
  146.  
  147. sendbit1:
  148.   X[0] = SHI
  149.   SLEEP FOR Half_Time
  150.   X[0] = SLO
  151.   SLEEP FOR Half_Time
  152. RETURN
(#) miki79 hozzászólása Máj 31, 2022 /
 
Sziasztok!
A kontrollerekkel kapcsolatban:amikor assemblyben írok egy programot az egyikfele a program memóriába kerűl ami nem változik?A másikfele az adat memóriába kerűl és a program futása közben változik vagy változhat?
A program futása közben amikor szoftveresen fut a program az adat memóriában történnek a dolgok és a "hardveresen megolott,, akkor a speciális funkció regisztereben pakolgat a program?

A programmal kapcsolatban:ha fetételezzük egy, 1db LED villogtató programot megírhatok úgy is, ha adat memóriába beírok egy 1db bitet és azt rákűldöm a A PORT kimenetre aztán megszakítás, visszetérés a program elejére. Az időzítés lenyegtelen. Tudom:"hardverese egyszerűbb!"
(#) sonajkniz válasza miki79 hozzászólására (») Máj 31, 2022 /
 
Ha megírsz és beégetsz egy programot, az mind a programmemóriába kerül.
A program futása közben kerülnek a RAM-ba át adatok.
Ha te valami adatot egyből RAM-ba szeretnél tenni, akkor azt inicializálás után a programmal kel áttöltetni a programmemóriából. Ha viszont arra van szükséged, hogy ezek az adatok esetleges változásai megmaradjanak, ne íródjanak felül egy reset, vagy kikapcsolás során, akkor elvben van lehetőséged ezeket az adatokat a programozóval egyből EEPROM-ba írni, onnan áttölteni a RAM-ba, majd kikapcsolás előtt a RAM-ban lévő adatokkal az EEPROM-ot átírni.
(#) kissi válasza miki79 hozzászólására (») Máj 31, 2022 /
 
Szia!

A megírt program ( ami tartalmazhat konstansokat, táblázatokat is!) mindenképpen a programmemóriába kerül és amit akarsz, az kerül át később ebből a RAM-ba, ill. és/vagy a program futása során keletkező eredmények képződnek a RAM-ba, a program futása a programmemóriából történik (Harvard architektúra!), szemben a PC-kkel (Neumann architektúra!).
A speciális funkciójú regiszterek (SFR) szintén RAM cellák, csak annyiban kitüntetettek, hogy a bennük lévő bitek a kontrollerben található perifériák ( hardverelemek ) működésére kihatással vannak, de ugyanúgy lehet őket módosítani, kiolvasni, írni általában, mint egy tetszőleges, általános célú RAM cellát (viszont egyedi, kis eltérések lehetnek --biblia: adatlap ! ) !

Remélem érthető volt ?!
A hozzászólás módosítva: Máj 31, 2022
(#) Broy hozzászólása Jún 14, 2022 /
 
Sziasztok!
A segítségeteket szeretném kérni. Van egy low pin count boardom és abba tettem egy 16F1823-at. Egy éve még teljesen jól tudtam programozni a rendszert, de most újra elővettem és bármit csinálok (pl. üres főciklus, üres Timer1), a beírás után a négy LED-ből (RC0-RC3) az RC0-ra és az RC2-re kötött LEDek felgyulladnak és úgy is maradnak, a másik kettő nem ég (ez a helyes állapot). Ha bármilyen programot égetek be, ugyanezt tapasztalom. Természetesen a regisztereket megfelelően beállítom és törlöm (régebben nem volt a programmal semmi gond, csak a teszt miatt töröltem ki a végrehajtó részeket). Egy másik 1823-at beletettem, ugyanazt az eredményt kaptam. A belső RC oszcillátor frekvenciája 4 MHz.
MPLAB X IDE V6-ot használok, de az 5.4-el is ugyanez volt. Az MPLAB nem ír hibát, minden rendben lezajlik. A használt számítógép is ugyanaz. Az égető egy PICKIT3.
Mivel tesztelhetném, hogy hol lehet a gond?
(#) kissi válasza Broy hozzászólására (») Jún 14, 2022 /
 
Szia!

A projektben benne van az a file, amit módosítasz? Mert amiket írsz, az nagyon azt mutatja, hogy nem abban a file-ban dolgozol, ami lefordul és beletöltődik a PIC-be !
(#) Broy válasza kissi hozzászólására (») Jún 14, 2022 /
 
Hú, ez lehet. Benne van, de 2 db file is van benne. Holnap megnézem. Ezer köszönet.
(#) Broy válasza kissi hozzászólására (») Jún 15, 2022 /
 
Minden rendben működik. Csináltam egy új projektet. Köszi.
(#) Naresh Jain válasza Hp41C hozzászólására (») Jún 21, 2022 /
 
Dear Sir, I need your help again, I have the codes to control the traic to control the speed of fan using 16F676 schematic 1 working successfully and codes attached below, now I want some amendment in codes to toggle control one more triac on another port as schematic 2 attached below, Please help me
  1. /********************************************************************************
  2. *                   Fan Controller                                              *
  3. *                                                                               *
  4. *   This program is free software: you can redistribute it and/or modify        *
  5. *   it under the terms of the GNU General Public License as published by        *
  6. *   the Free Software Foundation, either version 3 of the License, or           *
  7. *   (at your option) any later version.                                         *
  8. *                                                                               *
  9. *   This program is distributed in the hope that it will be useful,             *
  10. *   but WITHOUT ANY WARRANTY; without even the implied warranty of              *
  11. *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
  12. *   GNU General Public License for more details.                                *
  13. *                                                                               *
  14. *   You should have received a copy of the GNU General Public License           *
  15. *   along with this program.  If not, see <https://www.gnu.org/licenses/>.      *
  16. *                                                                               *
  17. *       Date            : Friday, 21 January 2011                               *
  18. *       Author          : C.V.Niras/VU3CNS                                      *
  19. *       Copyright       : (C) 2010 C. V. Niras                                  *
  20. *       Email           : cvniras@gmail.com                                     *
  21. *       Processor       : 12F675                                                *
  22. *       First Release   : 23/01/2011                                            *
  23. *       Ver             : 0.7                                                   *
  24. *   Change History:                                                             *
  25. *       Rev     Date        Description                                         *
  26. *       0.5     06/03/2011  First stable release                                *
  27. *       0.6     08/03/2011  Bug fixed - Can't swich on by CH+, when turned      *
  28. *                           off by set speed to 0                               *
  29. *       0.7     14/06/2011  Trigger off delayed for full speed (low firing      *
  30. *                           angle) to reach the TRIAC latch current             *
  31. *                                                                               *
  32. *********************************************************************************/
  33. #include <pic.h>
  34. #include "type_def.h"
  35. #include "remote_commands.h"
  36.  
  37. #if defined _12F675
  38. __CONFIG(WDTDIS & MCLRDIS & INTIO & BORDIS & UNPROTECT & PWRTEN);
  39.  
  40. #define IsIRDataBitHigh()   GPIO3 == 0  // Inverted logic
  41. #define SW_UP           _GPIO,0         // Up switch
  42. #define SW_DN           _GPIO,2         // Down switch
  43. #define LEDOn()         GPIO1 = 1       // LED
  44. #define LEDOff()        GPIO1 = 0
  45. #define TriacOn()       GPIO5 = 0       // Triac
  46. #define TriacOff()      GPIObits.GPIO5 = 1
  47. #define TRIAC           GPIO5           // Triac pin
  48. #endif  
  49.  
  50. #if defined _16F676
  51. __CONFIG(WDTDIS & MCLRDIS & INTOSCIO & BORDIS & UNPROTECT & PWRTEN);
  52.  
  53. #define GPIO PORTA
  54. #define TRISIO TRISA
  55. #define GPIF RAIF
  56. #define GPIE RAIE
  57.  
  58. #define IsIRDataBitHigh()   PORTAbits.RA3 == 0  // Inverted logic
  59. #define SW_UP           _PORTA,0         // Up switch
  60. #define SW_DN           _PORTA,2         // Down switch
  61. #define LEDOn()         PORTAbits.RA1 = 1       // LED
  62. #define LEDOff()        PORTAbits.RA1 = 0
  63. #define TriacOn()       PORTAbits.RA5 = 0       // Triac
  64. #define TriacOff()      PORTAbits.RA5 = 1
  65. #define TRIAC           PORTAbits.RA5           // Triac pin
  66. #endif
  67.  
  68. __EEPROM_DATA(5, 1, 1, 255, 255, 255, 255, 255);
  69.  
  70. __IDLOC7('0','.','7','B');
  71.  
  72. #define TIMER_ENABLE                    // Enable timer
  73. // -- Chip Configurations --
  74. #define _XTAL_FREQ      4000000
  75. #define ZC_PIN_MASK     0x10            // Pin used for zero cross detection
  76. #define IR_PIN_MASK     0x08            // IR sensor output
  77. #define TIME_COUNT      6866            // Number of Timer1 overflows in an hour
  78. #define ANY_KEY         Key & 0x80
  79. #define UP_KEY          Key & 0x01
  80. #define DN_KEY          Key & 0x02
  81.  
  82. // Timer 1 is the time base, 1 bit time = 8us; the NEC physical bit time is 560us = 70 Timer 1
  83. // The following time are set with a +/- 20% tolerance
  84.  
  85. #define IR_MARK_MIN_TIME    787
  86. #define IR_SPACE_MIN_TIME   219
  87. #define MIN_IR_BIT_TIME     56
  88. #define MAX_IR_BIT_TIME     84
  89.  
  90. // -- End of Chip Configurations --
  91.  
  92. #define IRRx            Flag.b0         // New IR bit received
  93. #define IRNewHit        Flag.b1         // A new IR command received
  94. #define Error           Flag.b2         // General error flag
  95. #define IRCmdRepeat     Flag.b3         // A IR repeat command received
  96. #define StartFan        Flag.b4         // Indicate to start the fan
  97. #define EEPromWrite     Flag.b5         // Indicate to write to EEPROM
  98. #define UnknownCmd      Flag.b6         // Unused IR command
  99.  
  100. #define EETimeUpdate    Flag1.b0        // Indicate to update time in eeprom
  101. #define IR05Seconds     Flag1.b1        // A 0.5 seconds of IR inactivity, used to clear IR command repeate flag
  102. #define ClearLED        Flag1.b2        // Need to turn off LED
  103.  
  104. #define FanOn           Status.b0       // Fan Running
  105. #define TimerRunning    Status.b1       // Timer Running
  106.  
  107. #define AddZeroToIRData()   IRData._dword >>= 1                                 // Add a 0 bit to IR data
  108. #define AddOneToIRData()    IRData._dword >>= 1; IRData._dword |= 0x80000000    // Add a 1 bit to IR data
  109.  
  110. // NEC IR protocol states
  111. typedef enum _NEC_STATES
  112. {
  113.     IR_IDLE,
  114.     IR_MARK,
  115.     IR_SPACE,
  116.     IR_HIGH,
  117.     IR_LOW,
  118.     IR_REPEAT
  119. } NEC_STATES;
  120.  
  121. // V A R I A B L E S
  122. //const unsigned char STable[10] = {0, 157, 165, 173, 181, 188, 195, 205, 216, 252};
  123. // Modified to latch low power (load) fans  low firing angle (on full speed)
  124. const unsigned char STable[10] = {0, 157, 165, 173, 181, 188, 195, 205, 216, 234};
  125. near volatile BYTE Flag, Flag1, Status;
  126. near NEC_STATES IRState;
  127. unsigned char IRDataCount, PhaseAngle, Speed, Time, Count;
  128. volatile near unsigned char EECounter, Ticks, Key, KeyCount;
  129. volatile unsigned int IRTime, TimeCounter;
  130. DWORD IRData;
  131.  
  132. // F U N C T I O N   P R O T O T Y P E S
  133. void IRHandler(void);
  134. void NECDecoder(void);
  135. void InitIR(void);
  136. void SetSpeed(void);
  137. void OffTimer(void);
  138. void OnTimer(void);
  139. void SetTimer(void);
  140. void GetEEVariables(void);
  141. void SetEEVariables(void);
  142. void KeyDelay(void);
  143. void interrupt isr(void);
  144. void Delay2s(void);
  145.  
  146. // M A I N
  147. void main(void)
  148. {
  149.     #asm
  150.         call    0x3ff
  151.                 bsf             STATUS, 5
  152.                 movwf   OSCCAL & 0x7f
  153.                 bcf             STATUS, 5
  154.     #endasm
  155.     GPIO    = 0;                                        // Clear PORT
  156.     TriacOff();                                         // Triac off
  157.     TRISIO  = ZC_PIN_MASK | IR_PIN_MASK | 0x05;         // IR, Zero cross and swiches
  158.     WPU     = 0x05;                                     // Weak pull up enabled for wwitches
  159.     IOC     = ZC_PIN_MASK | IR_PIN_MASK;                // Interrupt on change is enabled for GPIO2, GPIO4
  160.     ANSEL   = 0x00;                                     // All are digital i/o
  161.     CMCON   = 0x07;                                     // Comparators off
  162.     INTCON  = 0x68;                                     // Enable PEIE, Timer0, Port change interrupts
  163.     OPTION_REG  = 0x05;                                     // INT falling edge, Prescaler 1:64
  164.     T1CON   = 0x31;                                     // Prescaler 1:8, internal clk, TMR1ON
  165.     LEDOn();
  166.     Flag._byte = 0;                                     // Initialise flags and variables
  167.     Flag1._byte = 0;
  168.     InitIR();
  169.     GetEEVariables();                                   // Read variables  eeprom
  170.     IRState = IR_IDLE;                                  // Init IR state
  171.     if(FanOn)
  172.         StartFan = 1;
  173.     FanOn = 0;                                          // This created a fresh start
  174. #ifdef  TIMER_ENABLE
  175.     if(TimerRunning)                                    // If already started, set the time again
  176.         SetTimer();
  177. #endif
  178.     GIE = 1;                                            // Enable interrupts
  179.     SetSpeed();                                         // Set the speed
  180.     LEDOff();                                           // Turn off LED
  181.     Count = Time << 1;                                  // Count = Time * 2, i.e turn on/off
  182.     Ticks = 0;
  183.     do
  184.     {
  185.         NECDecoder();                                   // Decode NEC formatted IR data
  186.         if(IRNewHit)                                    // Is any new data?
  187.         {
  188.             IRNewHit = 0;                               // Y. Clear flag
  189.             IRHandler();                                // Do the command
  190.         }
  191.         if(IRCmdRepeat)                                 // As long as the repeat command present
  192.         {                                               // do not turn of LED
  193.             IRCmdRepeat = 0;
  194.             Ticks = 0;                                  // for the same clear Ticks
  195.         }
  196.         if(EEPromWrite)
  197.         {
  198.             EEPromWrite = 0;                            // Clear eeprom update flag
  199.             SetEEVariables();                           // Write variables if necessory
  200.         }
  201.         if(ClearLED)
  202.         {
  203.             if(Ticks & 0x20)                            // If remote command received, turn off LED after only
  204.             {                                           // few ms (~320ms)
  205.                 ClearLED = 0;
  206.                 LEDOff();
  207.             }
  208.         }
  209. #ifdef  TIMER_ENABLE
  210.         else if(TimerRunning && (Ticks & 0x40))         // If timer is running and a short time expired (640ms)
  211.         {                                               // used to blink LED to show the time remaining
  212.             if(Count == 0xF7)                           // Reload counter to show the time, after a certain time gap
  213.             {
  214.                 Count = Time << 1;                      // Count = Time * 2, i.e turn on/off
  215.                 LEDOff();                               // Ensure LED is off
  216.             }
  217.             if(!(--Count & 0x80))                       // Blinks the LED till counter become -ve
  218.             {
  219.                 if(Count & 0x01) {                      // On odd numbers in counter LED on
  220.                     LEDOn();
  221.                 }
  222.                 if(!(Count & 0x01)) {                   // For even numbers LED off
  223.                     LEDOff();
  224.                 }
  225.             }
  226.             Ticks = 0;                                  // Reset ticks
  227.         }//if(TimerRunning && (Ticks & 0x40))
  228. #endif
  229.  
  230.         if(KeyCount >= 4)                               // Has key pressed for a short time?
  231.         {
  232.             if(UP_KEY)                                  // Y. Check for Up key press
  233.             {
  234.                 StartFan = 1;                           // Y. Up key pressed, inc the speed
  235.                 Speed++;
  236.             }
  237.             if(DN_KEY)                                  // Check for a down key press
  238.             {
  239.                 StartFan = 1;                           // Y. Down key pressed, decrement the speed
  240.                 Speed--;
  241.             }
  242.             if(StartFan)                                // If any key pressed, do the action
  243.             {
  244.                 SetSpeed();
  245.                 KeyDelay();                             // Give a delay beore the next check
  246.             }
  247.         }
  248.     }while(1);
  249. }// main
  250.  
  251. // F U N C T I O N S
  252. /**
  253. The function is used to decode IR commands and make changes required
  254. */
  255. void IRHandler(void)
  256. {
  257.     if(!(IRData.byte0 ^ IRData.byte1) == 0)             // Address and its compliment match
  258.      {
  259.          if(IRData.byte0 == 0)                          // Address  is zero
  260.          {
  261.              if(!(IRData.byte2 ^ IRData.byte3) == 0)    // Command and its compliment match
  262.              {
  263.                 UnknownCmd = 0;
  264.                 switch(IRData.byte2)
  265.                 {
  266.                     case VOL_PLUS:
  267.                     StartFan = 1;
  268.                     Speed++;
  269.                     break;
  270.                     case VOL_MINUS:
  271.                     StartFan = 1;
  272.                     Speed--;
  273.                     break;
  274.                     case DIGIT0:
  275.                     Speed = 0;
  276.                     OffTimer();
  277.                     break;
  278.                     case DIGIT1:
  279.                     StartFan = 1;
  280.                     Speed = 1;
  281.                     break;
  282.                     case DIGIT2:
  283.                     StartFan = 1;
  284.                     Speed = 2;
  285.                     break;
  286.                     case DIGIT3:
  287.                     StartFan = 1;
  288.                     Speed = 3;
  289.                     break;
  290.                     case DIGIT4:
  291.                     StartFan = 1;
  292.                     Speed = 4;
  293.                     break;
  294.                     case DIGIT5:
  295.                     StartFan = 1;
  296.                     Speed = 5;
  297.                     break;
  298.                     case DIGIT6:
  299.                     StartFan = 1;
  300.                     Speed = 6;
  301.                     break;
  302.                     case DIGIT7:
  303.                     StartFan = 1;
  304.                     Speed = 7;
  305.                     break;
  306.                     case DIGIT8:
  307.                     StartFan = 1;
  308.                     Speed = 8;
  309.                     break;
  310.                     case DIGIT9:
  311.                     StartFan = 1;
  312.                     Speed = 9;
  313.                     break;
  314.  
  315.                     case CH_MINUS:
  316.                     FanOn = 0;
  317.                     OffTimer();
  318.                     break;
  319.  
  320.                     case CH_PLUS:
  321.                     if(Speed == 0) Speed++;
  322.                     StartFan = 1;
  323.                     break;
  324.  
  325.                     case PREV:
  326.                     if(FanOn)   Time--;
  327.                     SetTimer();
  328.                     break;
  329.  
  330.                     case NEXT:
  331.                     if(FanOn)   Time++;
  332.                     SetTimer();
  333.                     break;
  334.  
  335.                     case EQ:
  336.                     OffTimer();
  337.                     break;
  338.  
  339.                     case PLAY:
  340.                     OnTimer();
  341.                     break;
  342.  
  343.                     default:
  344.                     UnknownCmd = 1;
  345.                     break;
  346.                 }
  347.                 if(!UnknownCmd){
  348.                     LEDOn();                // A new command received
  349.                     ClearLED = 1;           // Clear LED after a little time
  350.                     Ticks = 0;              // Reset timer ticks
  351.                     SetSpeed();
  352.                 }
  353.              }// if((IRData.byte0 ^ IRData.byte1) == 0)
  354.          }// if(IRData.byte3 == 0)
  355.      }//if((IRData.byte3 ^ IRData.byte2) == 0)
  356. }
  357. /**
  358. Off the timer, without changing previous set time
  359. */
  360. void OffTimer(void)
  361. {
  362.     TimerRunning = 0;                                   // Turn off timer
  363.     Time = eeprom_read(1);                              // Read the eeprom, value
  364.     EETimeUpdate = 1;                                   // Update time in the eeprom
  365.     EECounter = 0;                                      // Clear the eeprom counter to update eeprom
  366. }
  367. /**
  368. On timer, start with the previous set time, if the timer is not running
  369. */
  370. void OnTimer(void)
  371. {
  372.     if(FanOn == 1)                                      // Only start Timer when fan on
  373.     {
  374.         if(!TimerRunning)                               // Nothing to do if already started
  375.         {
  376.             TimerRunning = 1;                           // Start the timer
  377.             Time = eeprom_read(1);                      // Get time  eeprom
  378.             if(Time == 0)                               // If zero, switch on timer with a non zero value, i.e one hour
  379.                 Time++;
  380.             TimeCounter = TIME_COUNT;                   // Reload the counter
  381.             EETimeUpdate = 1;                           // Update time in the eeprom
  382.             EECounter = 0;                              // Clear the eeprom counter to update eeprom
  383.         }
  384.     }
  385. }
  386. /**
  387. Set the counters for the timer. When the counter reached zero, the fan will be turned off
  388. If the timer not running, it reload time value with the last saved value  the eeprom,
  389. otherwise adjust counters as required, and clear eeprom counter to update time value in the
  390. eeprom, for the same it set a EETimeUpdate flag
  391. */
  392. void SetTimer(void)
  393. {
  394.     if(Time & 0x80)                                     // A neg, so clear it
  395.         Time = 0;
  396.     if(Time > 8)
  397.         Time = 8;                                       // Max 8 hours
  398.     if(FanOn == 0)                                      // Nothing to do if fan is not running
  399.         return;
  400.     if(!TimerRunning && (Time != 0)) {                  // If decrementing, and time reached zero, on further
  401.         Time = eeprom_read(1);                          // decrements never start the timer, only start on
  402.         TimerRunning = 1;                               // increments, i.e when time not zero.
  403.         if(Time == 0)                                   // If zero, start with a non zero value
  404.             Time++;                                     // i.e. set to one
  405.     }
  406.     if(Time == 0)                                       // Stop timer, if time is zero
  407.         TimerRunning = 0;
  408.     TimeCounter = TIME_COUNT;                           //
  409.     EETimeUpdate = 1;                                   // Update time in the eeprom
  410.     EECounter = 0;                                      // Clear the eeprom counter to update eeprom
  411. }
  412. /**
  413. Set the speed and update phase angle for a given speed. If start fan flag is set, and fan not running
  414. it starts fan will full speed for a second, then changes to ed speed.
  415. */
  416. void SetSpeed(void)
  417. {
  418.     if(Speed & 0x80)                                    // A neg, keep it as zero
  419.         Speed = 0;
  420.     if(Speed >= 10)                                     // Reach the max.
  421.         Speed = 9;
  422.     if(Speed == 0){
  423.         StartFan = 0;                                   // For a zero speed, switch off
  424.         FanOn = 0;
  425.     }
  426.     if(StartFan){                                       // If required, try to start the fan
  427.         if(!FanOn){                                     // Already running?
  428.             FanOn = 1;                                  // No. Switch on fan
  429.             PhaseAngle = STable[9];                     // If just swiched on run it on full speed
  430.             Delay2s();                                  // for a short time
  431.         }
  432.         StartFan = 0;                                   // Clear the flag
  433.     }
  434.     if(FanOn == 0) OffTimer();
  435.     PhaseAngle = STable[Speed];                         // Set the phase angle for the speed
  436.     EECounter = 0;                                      // Update EEPROM
  437. }
  438. /**
  439. Decode the IR data received in NEC format
  440. */
  441. void NECDecoder(void)
  442. {
  443.     static unsigned int IRBitTime, PrevIRTimer;
  444.     #if 0
  445.     static unsigned char Port;
  446.     if((Port ^ GPIO) & IR_PIN_MASK)                     // IR line changed
  447.     {
  448.         *((unsigned char*)&IRTime) = TMR1L;             // Copy the current Timer 1 value (LSB)
  449.         *((unsigned char*)&IRTime + 1) = TMR1H;         // -- do -- (MSB)
  450.         Port = GPIO;
  451.         IRBitTime = IRTime - PrevIRTimer;
  452.         PrevIRTimer = IRTime;
  453.         if(IRBitTime & 0x0800)
  454.             IRState = IR_IDLE;               // Idle for more than 16 ms
  455.         IRRx = 0;
  456.     #else
  457.     if(IRRx)
  458.     {
  459.         IRBitTime = IRTime - PrevIRTimer;
  460.         PrevIRTimer = IRTime;
  461.         if(IRBitTime & 0x0800)
  462.             IRState = IR_IDLE;              // Idle for more than 16 ms
  463.         IRRx = 0;
  464.     #endif
  465.         Error = 0;
  466.         switch(IRState)
  467.         {
  468.             case IR_IDLE:
  469.             if(IsIRDataBitHigh())           // If it is a one, IR starting
  470.                 IRState++;                  // Now is IR_MARK
  471.             IRDataCount = 0;
  472.             IRData._dword = 0;
  473.             break;
  474.  
  475.             case IR_MARK:                   // Now IR Mark just over
  476.             if(IRBitTime < IR_MARK_MIN_TIME)
  477.             {
  478.                 Error = 1;                  // Less than specified mark time
  479.             }
  480.             IRState++;
  481.             break;
  482.  
  483.             case IR_SPACE:                  // Now IR space just over
  484.             if(IRBitTime < IR_SPACE_MIN_TIME)
  485.             {
  486.                 Error = 1;                  // Less than specified space time
  487.             }
  488.             if(IRBitTime < IR_SPACE_MIN_TIME * 2)
  489.             {
  490.                 IRState = IR_REPEAT;        // If it is less than 4.5 ms, it may be a repeat command
  491.                 break;
  492.             }
  493.             IRState++;                      // Space is 4.5 ms, now IR high
  494.             break;
  495.  
  496.             case IR_HIGH:                   // IR high just over, check it
  497.             if(((unsigned char) IRBitTime < MIN_IR_BIT_TIME) || ((unsigned char) IRBitTime > MAX_IR_BIT_TIME))
  498.             {
  499.                 Error = 1;                  // Too short or too long pulse
  500.             }
  501.             IRState++;
  502.             break;
  503.  
  504.             case IR_LOW:                    // IR low just over, check it
  505.             if(((unsigned char) IRBitTime < MIN_IR_BIT_TIME) || ((unsigned char) IRBitTime > MAX_IR_BIT_TIME * 3))
  506.             {
  507.                 Error = 1;                  // Too short or too long pulse
  508.             }
  509.             if((unsigned char) IRBitTime >= MIN_IR_BIT_TIME * 3)
  510.             {
  511.                 AddOneToIRData();           // Longer low time, add a one
  512.             }
  513.             else
  514.             {
  515.                 AddZeroToIRData();          // Short low time add a zero
  516.             }
  517.             IRDataCount++;                  // Increment the counter
  518.             IRState--;                      // Now is IR High
  519.             break;
  520.  
  521.             case IR_REPEAT:                 // In repeat, the 560us IR burst just over, check it now
  522.             if(((unsigned char) IRBitTime < MIN_IR_BIT_TIME) || ((unsigned char) IRBitTime > MAX_IR_BIT_TIME))
  523.             {
  524.                 IRCmdRepeat = 0;
  525.                 Error = 1;
  526.             }
  527.             IRCmdRepeat = 1;
  528.             IRState = IR_IDLE;
  529.             break;
  530.  
  531.         }// switch(IRState)
  532.         if(Error)
  533.         {
  534.             InitIR();
  535.         }
  536.         if(IRDataCount == 32)
  537.         {
  538.             IRNewHit = 1;
  539.             IRState = IR_IDLE;
  540.             IRDataCount = 0;
  541.             //IROff = 0;
  542.         }
  543.         IR05Seconds = 0;
  544.     }// if(IRRx)
  545. }
  546. /**
  547. Initialise IR states
  548. */
  549. void InitIR( void ) // initial IR engine
  550. {
  551.     IRState = IR_IDLE;
  552.     IRNewHit = 0;
  553.     IRCmdRepeat = 0;
  554.     IRDataCount = 0;
  555. }
  556. /**
  557. Read variables  eeprom
  558. */
  559. void GetEEVariables(void)
  560. {
  561.     Speed = eeprom_read(0);
  562.     Time = eeprom_read(1);
  563.     Status._byte = eeprom_read(2);
  564. }
  565. /**
  566. Write to eeprom, the variables
  567. */
  568. void SetEEVariables(void)
  569. {
  570.     // Compare with the eeprom variables and update if necessory
  571.     if(Speed != eeprom_read(0))
  572.         eeprom_write(0, Speed);
  573.     if(EETimeUpdate)                                    // Time may change while running, so only update
  574.     {                                                   // if user make changes
  575.         if(Time != eeprom_read(1))
  576.             eeprom_write(1, Time);
  577.         EETimeUpdate = 0;
  578.     }
  579.     if(Status._byte != eeprom_read(2))
  580.         eeprom_write(2, Status._byte);
  581. }
  582. /**
  583. Create a 2 seconds delay, used to start the fan
  584. */
  585. void Delay2s(void)
  586. {
  587.     unsigned char Count;
  588.     Count = 200;                                        // Make a 200 x 10 ms delay
  589.     while(--Count != 0)
  590.         __delay_ms(10);
  591. }
  592. /**
  593. Delay after a key press. This function retuns after a specified time or when no key pressed down
  594. */
  595. void KeyDelay(void)
  596. {
  597.     unsigned char ms;
  598.     ms = 250;                                           // 500 ms delay
  599.     do
  600.     {
  601.         if(!ANY_KEY)                                    // If key released, return
  602.             break;
  603.         __delay_ms(2);
  604.     }while(--ms != 0);
  605. }
  606.  
  607. void interrupt isr(void)
  608. {
  609.     static unsigned char PortStatus, PortChanges;
  610.     if(GPIF)
  611.     {
  612.         PortChanges = PortStatus;                       // Copy the previous value
  613.         PortStatus = GPIO;                              // Update PortStatus
  614.         GPIF = 0;                                       // Clear interrrupt
  615.         PortChanges ^= PortStatus;                      // Find the differences
  616.         if(PortChanges & ZC_PIN_MASK)                   // Zero cross
  617.         {
  618.             TMR0 = PhaseAngle;                          // Phase angle is controlled via TMR0, on interrupt it trigger
  619.             if(FanOn && (PhaseAngle >= STable[9])){     // For full speed hold trigger  now, and TMR0 interrupt (delayed
  620.                 TriacOn();                              // to reach TRIAC holding current) clear the trigger
  621.             }
  622.             Ticks++;                                    // Ticks @ 10 ms
  623.             {
  624.             #asm
  625.             INCFSZ      _KeyCount,W                     // Inc Key Count, but not beyond 255
  626.             MOVWF       _KeyCount
  627.             CLRW                                        // Clear W
  628.             BTFSS       SW_UP                           // Up Key pressed?
  629.             MOVLW       0x81                            // Y. Load W with 0x81
  630.             BTFSS       SW_DN                           // Down Key pressed?
  631.             MOVLW       0x82                            // Y. Load W with 0x82
  632.             MOVWF       _Key                            // Save W to Key
  633.             BTFSS       _Key,7                          // Has any key pressed?
  634.             CLRF        _KeyCount                       // N. Clear the counter
  635.             #endasm
  636.             }
  637.         }//if(PortChanges & ZC_PIN_MASK)
  638.         if(PortChanges & IR_PIN_MASK)                   // IR line changed
  639.         {
  640.             *((unsigned char*)&IRTime) = TMR1L;         // Copy the current Timer 1 value (LSB)
  641.             *((unsigned char*)&IRTime + 1) = TMR1H;     // -- do -- (MSB)
  642.             IRRx = 1;
  643.         }
  644.     }
  645.     if(T0IF)                                            // Interrupt depends on phase angle (TMR0 is set by phase angle)
  646.     {
  647.         if(FanOn){
  648.             TriacOn();                                  // Triac triggered
  649.         }
  650.         T0IF = 0;                                       // Clear flag
  651.         NOP();
  652.         NOP();
  653.         NOP();
  654.         NOP();
  655.         TriacOff();                                     // Triac off, beacuse already triggered
  656.     }//if(T0IF)
  657.  
  658.     if(TMR1IF)                                          // @ 524ms; This interrupt is not set, but polled
  659.     {                                                   // with other interrupts
  660.         TMR1IF = 0;
  661. #ifdef  TIMER_ENABLE
  662.         if(TimerRunning && (--TimeCounter == 0))        // If timer running, decrement counter
  663.         {
  664.             TimeCounter = TIME_COUNT;                   // Reload counter
  665.             if(--Time == 0)                             // The time expired, switch off fan and counter
  666.             {
  667.                 OffTimer();                             // Switch off timer
  668.                 FanOn = 0;
  669.             }
  670.         }
  671. #endif
  672.         {
  673.         #asm
  674.         INCFSZ  _EECounter,W                            // Inc eeprom timer, but not beyond 255
  675.         MOVWF   _EECounter
  676.         #endasm
  677.         }
  678.         if(EECounter == 8)                              // After 4 seconds since clearing the counter
  679.             EEPromWrite = 1;                            // set eeprom write flag
  680.         if(IR05Seconds)                                 // After 0.5 seconds of inactivity
  681.             IRCmdRepeat = 0;                            // clear the repeat command
  682.         IR05Seconds = 1;
  683.     }//if(TMR1IF)
  684. }
what will change in codes:
(#) Hp41C válasza Naresh Jain hozzászólására (») Jún 21, 2022 /
 
Hi,

first you need to find two IR command codes not used yet by the program. Found a list of NEC IR keycodes with CH, CH100 and CH200 codes.

Add these codes to the list "in remote_commands.h".
  1. CH100         = 0x19,     // triac2 on
  2.     CH200         = 0x0D      // triac2 off


Put theses defines next to "#define TRIAC PORTAbits.RA5 // Triac pin"

  1. #define Triac2On()      PORTCbits.RC5 = 0       // Triac2
  2.     #define Triac2Off()     PORTCbits.RC5 = 1
  3.     #define TRIAC2          PORTCbits.RC5           // Triac2 pin


Extend the initializatiion with clearing PORTC and TRISC registers:
  1. void main(void)
  2.     {
  3.         #asm
  4.             call    0x3ff
  5.                     bsf             STATUS, 5
  6.                     movwf   OSCCAL & 0x7f
  7.                     bcf             STATUS, 5
  8.         #endasm
  9.         GPIO    = 0;                                        // Clear PORT
  10.         PORTC   = 0;
  11.         TriacOff();                                         // Triac off
  12.         TRISIO  = ZC_PIN_MASK | IR_PIN_MASK | 0x05;         // IR, Zero cross and swiches
  13.         TRISC   = 0x00;


Add two block to IRHandler function before default label:
  1. case CH100:
  2.                         Triac2On();
  3.                         break;
  4.  
  5.                         case CH200:
  6.                         Triac2Off();
  7.                         break;
A hozzászólás módosítva: Jún 21, 2022
(#) Naresh Jain válasza Hp41C hozzászólására (») Jún 21, 2022 /
 
Thank you very much for your very quick response, here is mid night now, I will try tomorrow, again thanks
(#) Naresh Jain válasza Hp41C hozzászólására (») Jún 22, 2022 /
 
Dear sir, I am very poor in coding I tried many times but failed, please add the codes in main.c attached belew ,consider the two commands same as CH100 = 0X19 and CH200 =0X0D :
A hozzászólás módosítva: Jún 22, 2022
(#) Naresh Jain válasza Naresh Jain hozzászólására (») Jún 22, 2022 /
 
Sorry for mistake,
Correct commands are :
CH100 =1A,
CH200 =0E
(#) Hp41C válasza Naresh Jain hozzászólására (») Jún 22, 2022 /
 
Hi,
remote_commands.h is correct. Modified main.c attaxhed.

main.c
    
(#) Naresh Jain válasza Hp41C hozzászólására (») Jún 22, 2022 /
 
Sir I failed to compile with this main.c, I think I made some mistakes,screen shot attached :
(#) Broy hozzászólása Jún 22, 2022 /
 
Sziasztok!
Még egy probléma merült fel. Sikerült a próba panelen megírni a kódot, tökéletesen működik.
A digitális bemenet (egy kapcsoló) itt a PIC16f1823 A3 lábára kapcsolódik. Mikor a kész nyákra beültetett IC-n futtatom a kódot, minden működik csak a bemenet nem, itt az A5-re van téve a bemenet. Ha átteszem kódban egy másik lábra (pl. A2) a bemenetet, akkor működik (jumperrel kapcsolva). Valaki találkozott már ilyen esettel? Ha végképp nem megy, akkor átdrótozom a nyákot, de jó lenne anélkül megoldani a problémát, mert 10db nyákról van szó. Annyit még hozzá, hogy a nyákon 12V-ról működik a kapcsoló, amit ellenállással és Zenerrel vágok meg, a A5 bemenet lábán mérhető feszültségszintek kapcsoláskor 0V és 4,4V.
(#) Elektro.on válasza Broy hozzászólására (») Jún 22, 2022 /
 
Szia!

Az RA4 és RA5 lábai alapból az oszcillátor bemenetek. Nyilván te a belső oszcillátorát használod. valószínű a konfigurációs beállítása hibás, és nem bemenetkénk kezeli az adott lábakat.
(#) Elektro.on válasza Elektro.on hozzászólására (») Jún 22, 2022 /
 
Ezen kívűl a TIMER1 bemenete is lehet az RA5. Adatlap 172. oldaltól olvasd el.
(#) Broy válasza Elektro.on hozzászólására (») Jún 22, 2022 /
 
Ezt láttam az adatlapban, csak nem tudtam, hogy mit kell (kell-e) kezdeni vele valamit. A belső oszcillátort használom. Jelenleg csak a digitális beállítást, inputra állítást és a törlést csinálom meg. Végignéztem az adatlapot és nem értem, hogy kell ezeket a függőségeket a különböző regisztereken keresztül (ki-be)kapcsolni. Azt hittem, hogy a general I/O pin az alapbeállítás és a különböző extra funkciókat külön kell kapcsolni. Tudna valaki segíteni?
Következő: »»   1178 / 1203
Bejelentkezés

Belépés

Hirdetés
Lapoda.hu     XDT.hu     HEStore.hu
Az oldalon sütiket használunk a helyes működéshez. Bővebb információt az adatvédelmi szabályzatban olvashatsz. Megértettem