![2Bit](/img/default-banner.jpg)
- 154
- 159 723
2Bit
Canada
Приєднався 14 чер 2017
Howdy do! Thanks for checking out my channel. I live in Southern Ontario, Canada. My channel features my hobbies: electronics, radio and learning.
I am no expert, but I am a hobbyist. This is why I chose the name "2Bit."
two-bit
/ˈto͞o ˌbit/
adjectiveINFORMAL•NORTH AMERICAN
insignificant, cheap,
"some two-bit town"
I am proud of my channel. And, my name reflects that I'm not a pro.
Life is too short for making things perfect and precise.
Being hasty and imprecise is more fun!!!
I am no expert, but I am a hobbyist. This is why I chose the name "2Bit."
two-bit
/ˈto͞o ˌbit/
adjectiveINFORMAL•NORTH AMERICAN
insignificant, cheap,
"some two-bit town"
I am proud of my channel. And, my name reflects that I'm not a pro.
Life is too short for making things perfect and precise.
Being hasty and imprecise is more fun!!!
PIC16F684 Part 016 - Controlling Two Shift Registers
PIC16F684 Part 016 - Controlling Two Shift Registers
PIC16F684 datasheet: ww1.microchip.com/downloads/en/devicedoc/41202D.pdf
For more on the 74HC165 Shift Register (Parallel in Serial Out), please watch my video: ua-cam.com/video/jmDXDJjGNu0/v-deo.html
See the 74HC595 datasheet: www.ti.com/lit/ds/symlink/sn74hc595.pdf
PIC16F684 datasheet: ww1.microchip.com/downloads/en/devicedoc/41202D.pdf
PIC16F684 datasheet: ww1.microchip.com/downloads/en/devicedoc/41202D.pdf
For more on the 74HC165 Shift Register (Parallel in Serial Out), please watch my video: ua-cam.com/video/jmDXDJjGNu0/v-deo.html
See the 74HC595 datasheet: www.ti.com/lit/ds/symlink/sn74hc595.pdf
PIC16F684 datasheet: ww1.microchip.com/downloads/en/devicedoc/41202D.pdf
Переглядів: 147
Відео
PIC16F684 Part 015 - Controlling a 74HC165 Shift Register (Parallel in Serial Out)
Переглядів 159Місяць тому
PIC16F684 Part 015 - Controlling a 74HC165 Shift Register (Parallel in Serial Out) PIC16F684 datasheet: ww1.microchip.com/downloads/en/devicedoc/41202D.pdf For more on the 74HC165 Shift Register (Parallel in Serial Out), please watch my video: ua-cam.com/video/jmDXDJjGNu0/v-deo.html
PIC16F684 Part 014 - Problems with Port bits clearing unintended? Turn the comparators off.
Переглядів 71Місяць тому
PIC16F684 Part 014 - Problems with Port bits clearing unintended? Turn the comparators off. PIC16F684 datasheet: ww1.microchip.com/downloads/en/devicedoc/41202D.pdf For more on the 74HC165 Shift Register (Parallel in Serial Out), please watch my video: ua-cam.com/video/jmDXDJjGNu0/v-deo.html
PIC16F684 Part 013 - Assembly Code Basics: Directives and more
Переглядів 212Місяць тому
PIC16F684 Part 013 - Assembly Code Basics: Directives and more PIC16F684 datasheet: ww1.microchip.com/downloads/en/devicedoc/41202D.pdf
PIC16F684 Part 012 - Assembly Code Basics: Bank Switching and more
Переглядів 156Місяць тому
PIC16F684 Part 012 - Assembly Code Basics: Bank Switching and more PIC16F684 datasheet: ww1.microchip.com/downloads/en/devicedoc/41202D.pdf
74HC165 Shift Register (Parallel in Serial Out)
Переглядів 1,7 тис.Місяць тому
74HC165 Shift Register (Parallel in Serial Out) Datasheet: www.ti.com/lit/ds/symlink/sn74hc165.pdf See my vid on the Debounced Multi-Switch Digital Module: ua-cam.com/video/YXBX9Thghsw/v-deo.html
The PIC10F200 Series: Part 019 The Counter, Final Project
Переглядів 86Місяць тому
The PIC10F200 Series: Part 019 The Counter, Final Project Check out the PIC10F200 video playlist on my channel! Watch my lead-up videos to this one! PIC10F200 Part 017: ua-cam.com/video/yZ56rulkOYQ/v-deo.html PIC10F200 Part 016: ua-cam.com/video/ia_b3q_cnJ8/v-deo.html Debounced Multi-Switch Digital Module: ua-cam.com/video/YXBX9Thghsw/v-deo.html 74HC595 Shift Register (Serial in Parallel Out): ...
PIC16F684 Part 011 - Controlling a 74HC595 Shift Register, Carry Bit?
Переглядів 186Місяць тому
PIC16F684 Part 011 - Controlling a 74HC595 Shift Register, Carry Bit? Watch my 74HC595 Shift Register (Serial in Parallel Out) video: ua-cam.com/video/bYiwaYWO7II/v-deo.html See the 74HC595 datasheet: www.ti.com/lit/ds/symlink/sn74hc595.pdf PIC16F684 datasheet: ww1.microchip.com/downloads/en/devicedoc/41202D.pdf
PIC16F684 Part 010 - Optimizing Code and RRF Instruction
Переглядів 80Місяць тому
PIC16F684 Part 010 - Optimizing Code and RRF Instruction Watch my 74HC595 Shift Register (Serial in Parallel Out) video: ua-cam.com/video/bYiwaYWO7II/v-deo.html See the 74HC595 datasheet: www.ti.com/lit/ds/symlink/sn74hc595.pdf PIC16F684 datasheet: ww1.microchip.com/downloads/en/devicedoc/41202D.pdf
PIC16F684 Part 009 - Controlling a 74HC595 Shift Register (Serial in Parallel Out)
Переглядів 91Місяць тому
PIC16F684 Part 009 - Controlling a 74HC595 Shift Register (Serial in Parallel Out) Watch my 74HC595 Shift Register (Serial in Parallel Out) video: ua-cam.com/video/bYiwaYWO7II/v-deo.html See the 74HC595 datasheet: www.ti.com/lit/ds/symlink/sn74hc595.pdf PIC16F684 datasheet: ww1.microchip.com/downloads/en/devicedoc/41202D.pdf
PIC16F684 Part 008 - Block Diagram
Переглядів 79Місяць тому
PIC16F684 Part 008 - Block Diagram ww1.microchip.com/downloads/en/devicedoc/41202D.pdf
PIC16F684 Part 007 - Block Diagram
Переглядів 74Місяць тому
PIC16F684 Part 007 - Block Diagram ww1.microchip.com/downloads/en/devicedoc/41202D.pdf
PIC16F684 Part 006 - Block Diagram
Переглядів 742 місяці тому
PIC16F684 Part 006 - Block Diagram ww1.microchip.com/downloads/en/devicedoc/41202D.pdf
PIC16F684 Part 005 - Block Diagram
Переглядів 772 місяці тому
PIC16F684 Part 005 - Block Diagram ww1.microchip.com/downloads/en/devicedoc/41202D.pdf
PIC16F684 Part 004 - Block Diagram
Переглядів 732 місяці тому
PIC16F684 Part 004 - Block Diagram ww1.microchip.com/downloads/en/devicedoc/41202D.pdf
PIC16F684 Part 002 - General Overview
Переглядів 1132 місяці тому
PIC16F684 Part 002 - General Overview
Using the Arduino to Evaluate the Stock Market
Переглядів 1918 місяців тому
Using the Arduino to Evaluate the Stock Market
The PIC10F200 Series: Part 018: 74HC595 Shift Register, 555 timer
Переглядів 31511 місяців тому
The PIC10F200 Series: Part 018: 74HC595 Shift Register, 555 timer
The PIC10F200 Series: Part 017: 74HC595 Shift Register, Continued
Переглядів 8511 місяців тому
The PIC10F200 Series: Part 017: 74HC595 Shift Register, Continued
The PIC10F200 Series: Part 016: 74HC595 Shift Register
Переглядів 150Рік тому
The PIC10F200 Series: Part 016: 74HC595 Shift Register
The PIC10F200 Series: Part 015: Another Blink Program (But Grumpier)
Переглядів 77Рік тому
The PIC10F200 Series: Part 015: Another Blink Program (But Grumpier)
74HC595 Shift Register (Serial in Parallel Out)
Переглядів 316Рік тому
74HC595 Shift Register (Serial in Parallel Out)
Debounced Multi-Switch Digital Module (using a hex inverter)
Переглядів 106Рік тому
Debounced Multi-Switch Digital Module (using a hex inverter)
PIC18F4525 Part 021: Timer as Delay and Adjusting Prescaler (in C Language)
Переглядів 47Рік тому
PIC18F4525 Part 021: Timer as Delay and Adjusting Prescaler (in C Language)
PIC18F4525 Part 020: Timers as Delay, More! (in C Language)
Переглядів 34Рік тому
PIC18F4525 Part 020: Timers as Delay, More! (in C Language)
PIC18F4525 Part 019: Timers More! (in Assembly Language)
Переглядів 69Рік тому
PIC18F4525 Part 019: Timers More! (in Assembly Language)
Four years and i'm the first comment. Thanks for this. It's not the easiest to understand but I get the gist. I'm a HAM radio Operator and am always learning.
;free sample code, copy and paste processor 16F684 include "p16f684.inc" ; Configuration settings __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF R1 EQU 0x20 ; outer loop counter R2 EQU 0x21 ; inner loop counter C2 EQU 0X23 ; specify file to store an 8 bit value C1 EQU 0X22 ; specify file to store an 8 bit value ; Define connections #define SH_LD PORTC, 0 ; RC0 connected to SH_LD (pin 1) of 74HC165, config as output #define CLK PORTC, 1 ; RC1 connected to CLK (pin 2) of 74HC165, config as output #define SER_OUT_CHECK PORTC, 2 ; RC2 connected to SER_OUT (pin 3) of 74HC165, config as input #define PUSH_BUTTON_CHECK PORTC, 3 ; RC3 connected to external push button controlled by user, config as input #define SER_IN PORTA, 0 ; RA0 connected to 74HC595 SER_IN #define L_Clock PORTA, 1 ; RA1 connected to 74HC595 L_Clock #define Clock PORTA, 2 ; RA2 connected to 74HC595 Clock ; Main program start org 0x0000 goto Initialize ; Main program Initialize: ; Initialize ports banksel CMCON0 ; Select bank containing CMCON register movlw 0x07 ; Load 0x07 into WREG (binary 00000111) movwf CMCON0 ; Move WREG into CMCON to turn off comparators bsf STATUS, RP0 ; Switch to Bank 1 clrf ANSEL ; Set all pins to digital (for PORTC) movlw b'00001100' ; Load W with the value 00001100 (binary) movwf TRISC ; Set PORTC pin 2 and pin 3 as input and others as output bcf STATUS, RP0 ; Switch to Bank 0 bsf STATUS, RP0 ; Switch to Bank 1 clrf ANSEL ; Set all pins to digital clrf TRISA ; Set all pins of PORTA as output bcf STATUS, RP0 ; Switch to Bank 0 CLRF C1 CLRF C2 MOVLW b'00000011' ; Pin 1 and 2 (Shift/Load and clock ) on 74HC165, triggered from High to LOW, so set high MOVWF PORTC ; this sets Shift/Load and clock both high Check_Button btfss PUSH_BUTTON_CHECK ; Check if the button (PORTC pin 3) is pressed goto Check_Button CALL DELAY SHIFT_LOAD ; might label as "Loop" BCF SH_LD ;PORTC, 0 CALL DELAY BSF SH_LD ; the preceding three lines load 8 bits of data into 74HC165 BTFSC SER_OUT_CHECK ; check the logic level of the SER_OUT pin of 74HC165 CALL IF_MSB_HIGH BTFSS SER_OUT_CHECK CALL IF_MSB_LOW CALL BIT_TESTER IF_MSB_HIGH ; the need for this relies upon a technical function of the 74HC165 MOVLW b'10000000' ; the first bit of data (MSB) doesn't require being clocked in MOVWF C2 RETLW 0 IF_MSB_LOW MOVLW b'00000000' ; the first bit of data (MSB) doesn't require being clocked in MOVWF C2 RETLW 0 BIT_TESTER CALL CLOCK_ROUTINE ; this advances to the next bit BTFSC SER_OUT_CHECK ; check the logic level of the SER_OUT pin of 74HC165 BSF C2, 6 BTFSS SER_OUT_CHECK BCF C2, 6 CALL DELAY CALL CLOCK_ROUTINE ; bit 5 BTFSC SER_OUT_CHECK BSF C2, 5 BTFSS SER_OUT_CHECK BCF C2, 5 CALL DELAY CALL CLOCK_ROUTINE ; bit 4 BTFSC SER_OUT_CHECK BSF C2, 4 BTFSS SER_OUT_CHECK BCF C2, 4 CALL DELAY CALL CLOCK_ROUTINE ; bit 3 BTFSC SER_OUT_CHECK BSF C2, 3 BTFSS SER_OUT_CHECK BCF C2, 3 CALL DELAY CALL CLOCK_ROUTINE ; bit 2 BTFSC SER_OUT_CHECK BSF C2, 2 BTFSS SER_OUT_CHECK BCF C2, 2 CALL DELAY CALL CLOCK_ROUTINE ; bit 1 BTFSC SER_OUT_CHECK BSF C2, 1 BTFSS SER_OUT_CHECK BCF C2, 1 CALL DELAY CALL CLOCK_ROUTINE ; bit 0 BTFSC SER_OUT_CHECK BSF C2, 0 BTFSS SER_OUT_CHECK BCF C2, 0 CALL DELAY MOVF C2, W ; this takes the data from the first register and writes to the second MOVWF C1 BITTESTER BTFSC C1, 0 BSF SER_IN ; PORTA, 0 (RA0) controls the serial input on the shift register CALL DELAY CALL SHIFT_CODE BTFSC C1, 1 BSF SER_IN CALL DELAY CALL SHIFT_CODE BTFSC C1, 2 BSF SER_IN CALL DELAY CALL SHIFT_CODE BTFSC C1, 3 BSF SER_IN CALL DELAY CALL SHIFT_CODE BTFSC C1, 4 BSF SER_IN CALL DELAY CALL SHIFT_CODE BTFSC C1, 5 BSF SER_IN CALL DELAY CALL SHIFT_CODE BTFSC C1, 6 BSF SER_IN CALL DELAY CALL SHIFT_CODE BTFSC C1, 7 BSF SER_IN CALL DELAY CALL SHIFT_CODE BSF L_Clock ; L_CLOCK (PORTA, 1) sets or latches previously-sent 8 bits CALL DELAY BCF L_Clock ; L_CLOCK cleared back to low CALL DELAY GOTO Check_Button SHIFT_CODE ; shift register subroutine BSF Clock ; Clock pin (PORTA, 2), clocks in whatever serial input (PORTA, 0) is doing CALL DELAY BCF Clock CALL DELAY BCF SER_IN ;CALL DELAY RETLW 0 CLOCK_ROUTINE ; indiviually clock-in subsequent 7 bits BCF CLK CALL DELAY BSF CLK RETLW 0 DELAY MOVLW 0xFF ; adjusted delay time MOVWF R1 AGAIN MOVLW 0xFF MOVWF R2 HERE NOP NOP DECFSZ R2, F GOTO HERE DECFSZ R1, F GOTO AGAIN RETLW 0 END ; Needed to end the program.
Ive cascaded 2 of them with led ouputs - arduino to it ETC ,
Cool! Nice Work!
Note to self: latching ICs are available.
Wouldn't writing C code be much easier, and almost as fast as assembly?
You are correct. C language is much easier. However, C language is a higher level language. In C, there isn't always an intuitive understanding of how your programming is affecting the hardware components inside the chip. For instance, in Assembly, there is setting the timers for delay routines, setting bits in the special function registers, and manipulation of data memory locations. In C language, you can use the delay instruction to create delays, whereas in Assembly, you need to develop a delay routine using counters and possibly the internal timers. In C language, you can declare variables and the assembler automatically assigns variables to a memory location so you don't have to. In Assembly you have to designate memory locations and pay attention to the memory map (although, there is the CBlock directive). Here is another example. In C, you can create a "for loop." for (i = 1; i <= 10; i++) "i" initializes the counter to 1 i <= 10 checks if i is less than or equal to 10 i++ increases the value of i by 1 after each iteration To create a for loop in C language, all you have to do is remember the syntax (above). To create a similar type of "for loop" in Assembly, you have to have a deeper understanding of the memory locations. You have to create a memory location to store a counter. You have to increment (or decrement) the counter. You have to test whether the counter has reached 0; likely you might check the status register. To create a "for loop" In C language, there is almost no need to understand the registers. In Assembly you'll be writing directly to the registers. In Assembly, you'll need to know where the general purpose registers are in the RAM, so to assign counters. Possibly, you may need to check the Z (Zero Status Bit) in the Status Register. I'm not trying to sound technical. But this brings me to my next point. Writing in assembly forces you to learn about the architecture of the microcontroller. Even if you look at the datasheet of a PIC chip, all of the code examples are written in Assembly. Microchip almost assumes that everyone reading the data sheet can read Assembly language. If I may use an analogy, becoming an auto-mechanic requires you to study all the parts of car. Similarly, to understand a microcontroller, you'll have to study all of its parts too. You'll understand the chip much better when you start using Assembly language. And, it will force you to read the datasheet. In Assembly, most assembly instructions use 1 machine cycle (4 clock cycles). Although, several instructions, like "goto" and "call", use 2 instruction cycles. I had to look this up, but according to an Internet search, a "for loop," when using C language for a PIC microchip, uses 75 machine instruction cycles. (Determining the number of machine cycles may vary.) Myself included, I have no idea what internal hardware components/ RAM memory locations of the microcontroller are being used when I write a "for loop" in C Language. For me, Assembly Language is really about learning and understanding. Understanding assembly language provides a deeper insight into how the microcontroller operates. It helps in understanding the machine-level workings, which can be beneficial for debugging and optimization. Assembly Language is also more efficient and makes better use of the Program Memory. Historically, program memory and data storage had technological limitations. These PIC microcontrollers are 20-25 years old now. So, back then, writing more efficient code in Assembly made sense. It meant making efficient use of the chip. The PIC16F684 has 3.5 KB of Flash memory for program storage. An Arduino Uno has 32 KB of Program Memory (Flash) An ESP32 microcontroller has 4 MB to 16 MB of Flash memory. This is 1000x more than the PIC16F684. Haha! On the other hand, how many newbs getting into microcontrollers need 4 MB of program memory? And, how many hobbyists can sincerely say they write their own code up to 4 MB? (aside from copying and pasting sample code) Its like having a 12-car garage. For most, all the program memory space is unnecessary. 20-25 years ago there was a serious benefit to writing more compact Assembly code to program memory. Nowadays, program memory capability has increased. The need for efficient compact code has decreased. In my humble opinion, this is why C is more popular. In the marketplace, where time is money, writing code in C language gets consumer products (like coffee makers and fridges) to the market, faster. Also, in my opinion, Assembly language isn't harder. Its not better. But, I guarantee Assembly gives you a deeper understanding of the chip. It will also strengthen your knowledge of the chip, for when you do write code in C language. And, craziest of all, even if you don't love writing in Assembly, you can ask ChatGPT to write it for you. ChatGPT is not perfect, but it reduces hours of studying tedious textbooks. For example, you can ask ChatGPT to write you a delay routine in Assembly, and boom, its there. When personal computers came out in the early 1980s, men (mostly), spent time figuring out how to program them. Unfortunately, that past-time came and went as personal computers became more sophisticated. But, microcontrollers have revived that hobby. Programming a microchip is not much different. When I started learning Assembly, maybe three years ago, it looked dreadful to me. But, I realized it helped in understanding these PIC chips. And now, I actually like it better. Also consider, that you can buy a PIC10F200 chip for a dollar! Its a simple chip. It can't do much. But, you can add them to your electronics projects. Rather than trying to cram lots of seriously complex code into a single Arduino, you can reduce some of that complexity. Just have your $1.00 PIC10F200 chip (programmed in Assembly) do some of the simpler tasks. Sadly, a lot of what get presented in popular videos is really just advertising for electronics products available online. PIC10F200 chips are inexpensive, which probably don't make online retailers much money. They'd rather sell you the fanciest chip instead. They also can't sell Arduino Unos when everyone already owns one. So, for business reasons, they always introduce something "newer" or "better." Sometimes there is an assumption that the older chips, or assembly language are obsolete. To me, both are still very useful. Thanks for your question. Sorry I typed to much. I've been considering creating a video on this topic.
@@2bit661 You make a lot of good points! Once you master assembly, you can write very fast programs in the small memory space on a $1 pic chip. Back in the days of Commodore 64 and Apple //e, game programmers had to use assembly language to make a fast complex game in a small memory space.
Appreciate your efforts
I liked your video, easy to understand because it's a very clear explanation, you got my sub, thanks.
;free sample code, copy and paste processor 16F684 include "p16f684.inc" ; Configuration settings __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF R1 EQU 0x20 ; outer loop counter R2 EQU 0x21 ; inner loop counter C2 EQU 0X23 ; specify file to store an 8 bit value ; Define connections #define SH_LD PORTC, 0 ; RC0 connected to SH_LD (pin 1) of 74HC165, config as output #define CLK PORTC, 1 ; RC1 connected to CLK (pin 2) of 74HC165, config as output #define SER_OUT_CHECK PORTC, 2 ; RC2 connected to SER_OUT (pin 3) of 74HC165, config as input #define PUSH_BUTTON_CHECK PORTC, 3 ; RC3 connected to external push button controlled by user, config as input ; Main program start org 0x0000 goto Initialize ; Main program Initialize: ; Initialize ports banksel CMCON0 ; Select bank containing CMCON register movlw 0x07 ; Load 0x07 into WREG (binary 00000111) movwf CMCON0 ; Move WREG into CMCON to turn off comparators bsf STATUS, RP0 ; Switch to Bank 1 clrf ANSEL ; Set all pins to digital (for PORTC) movlw b'00001100' ; Load W with the value 00001100 (binary) movwf TRISC ; Set PORTC pin 2 and pin 3 as input and others as output bcf STATUS, RP0 ; Switch to Bank 0 CLRF C2 MOVLW b'00000011' ; Pin 1 and 2 (Shift/Load and clock ) on 74HC165, triggered from High to LOW, so set high MOVWF PORTC ; this sets Shift/Load and clock both high Check_Button btfss PUSH_BUTTON_CHECK ; Check if the button (PORTC pin 3) is pressed goto Check_Button CALL DELAY SHIFT_LOAD ; might label as "Loop" BCF SH_LD ;PORTC, 0 CALL DELAY BSF SH_LD ; the preceding three lines load 8 bits of data into 74HC165 BTFSC SER_OUT_CHECK ; check the logic level of the SER_OUT pin of 74HC165 CALL IF_MSB_HIGH BTFSS SER_OUT_CHECK CALL IF_MSB_LOW CALL BIT_TESTER IF_MSB_HIGH ; the need for this relies upon a technical function of the 74HC165 MOVLW b'10000000' ; the first bit of data (MSB) doesn't require being clocked in MOVWF C2 RETLW 0 IF_MSB_LOW MOVLW b'00000000' ; the first bit of data (MSB) doesn't require being clocked in MOVWF C2 RETLW 0 BIT_TESTER CALL CLOCK_ROUTINE ; this advances to the next bit BTFSC SER_OUT_CHECK ; check the logic level of the SER_OUT pin of 74HC165 BSF C2, 6 BTFSS SER_OUT_CHECK BCF C2, 6 CALL DELAY CALL CLOCK_ROUTINE ; bit 5 BTFSC SER_OUT_CHECK BSF C2, 5 BTFSS SER_OUT_CHECK BCF C2, 5 CALL DELAY CALL CLOCK_ROUTINE ; bit 4 BTFSC SER_OUT_CHECK BSF C2, 4 BTFSS SER_OUT_CHECK BCF C2, 4 CALL DELAY CALL CLOCK_ROUTINE ; bit 3 BTFSC SER_OUT_CHECK BSF C2, 3 BTFSS SER_OUT_CHECK BCF C2, 3 CALL DELAY CALL CLOCK_ROUTINE ; bit 2 BTFSC SER_OUT_CHECK BSF C2, 2 BTFSS SER_OUT_CHECK BCF C2, 2 CALL DELAY CALL CLOCK_ROUTINE ; bit 1 BTFSC SER_OUT_CHECK BSF C2, 1 BTFSS SER_OUT_CHECK BCF C2, 1 CALL DELAY CALL CLOCK_ROUTINE ; bit 0 BTFSC SER_OUT_CHECK BSF C2, 0 BTFSS SER_OUT_CHECK BCF C2, 0 CALL DELAY goto Check_Button CLOCK_ROUTINE ; indiviually clock-in subsequent 7 bits BCF CLK CALL DELAY BSF CLK RETLW 0 DELAY MOVLW 0xFF ; adjusted delay time MOVWF R1 AGAIN MOVLW 0xFF MOVWF R2 HERE NOP NOP DECFSZ R2, F GOTO HERE DECFSZ R1, F GOTO AGAIN RETLW 0 END ; Needed to end the program.
16:10 Correction: Does the PIC16F684 have a bank select register? The PIC16F684 microcontroller does not have a dedicated Bank Select Register (BSR). Instead, it uses the RP0 and RP1 bits in the STATUS register to select the active bank in the data memory (RAM).
Interesting way to interface old 8bits ports to communicate with serial eproms, wondering wich circuit would do the reverse way, get the serial signal and convert to parallel 8bits !
Thanks for asking. There is the 74HC595 Shift Register (Serial in Parallel Out). ua-cam.com/video/bYiwaYWO7II/v-deo.html
Good explanation video mate; I like how you explain the theory then put it into practice!
Not for the beginner or Analog guys. :)
Here is a great video that shows the use of the 74HC165 (parallel in serial out) shift register: ua-cam.com/video/yna3iJa1hzg/v-deo.html
;free sample code, copy and paste processor 16F684 include "p16f684.inc" ; Configuration settings __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF R1 EQU 0x20 ; outer loop counter R2 EQU 0x21 ; inner loop counter C1 EQU 0X22 ; specify file to experiment with ; Define connections #define SER_IN PORTA, 0 ; RA0 connected to 74HC595 SER_IN #define L_Clock PORTA, 1 ; RA1 connected to 74HC595 L_Clock #define Clock PORTA, 2 ; RA2 connected to 74HC595 Clock ; Main program start org 0x0000 goto Initialize ; Main program Initialize: ; Initialize ports bsf STATUS, RP0 ; Switch to Bank 1 clrf ANSEL ; Set all pins to digital clrf TRISA ; Set all pins of PORTA as output bcf STATUS, RP0 ; Switch to Bank 0 CLRF C1 LOOP BITTESTER BTFSC C1, 0 BSF SER_IN ; PORTA, 0 (RA0) controls the serial input on the shift register CALL DELAY CALL SHIFT_CODE BTFSC C1, 1 BSF SER_IN CALL DELAY CALL SHIFT_CODE BTFSC C1, 2 BSF SER_IN CALL DELAY CALL SHIFT_CODE BTFSC C1, 3 BSF SER_IN CALL DELAY CALL SHIFT_CODE BTFSC C1, 4 BSF SER_IN CALL DELAY CALL SHIFT_CODE BTFSC C1, 5 BSF SER_IN CALL DELAY CALL SHIFT_CODE BTFSC C1, 6 BSF SER_IN CALL DELAY CALL SHIFT_CODE BTFSC C1, 7 BSF SER_IN CALL DELAY CALL SHIFT_CODE BSF L_Clock ; L_CLOCK (PORTA, 1) sets or latches previously-sent 8 bits CALL DELAY BCF L_Clock ; L_CLOCK cleared back to low CALL DELAY RRF C1, F ; rotate right f through carry GOTO LOOP SHIFT_CODE ; shift register subroutine BSF Clock ; Clock pin (PORTA, 2), clocks in whatever serial input (PORTA, 0) is doing CALL DELAY BCF Clock CALL DELAY BCF SER_IN CALL DELAY RETLW 0 DELAY MOVLW 0x80 ; adjusted delay time MOVWF R1 AGAIN MOVLW 0x20 MOVWF R2 HERE NOP NOP DECFSZ R2, F GOTO HERE DECFSZ R1, F GOTO AGAIN RETLW 0 END ; Needed to end the program.
6502 cpu
Thanks for your comment. I searched UA-cam for "6502 cpu" and found this video: ua-cam.com/video/acUH4lWe2NQ/v-deo.html Wow! I didn't realize such a chip was so popular and widely used. I am learning too. I didn't realize hobbyists can program these chips: ua-cam.com/video/k1iv2ANb2Ko/v-deo.html Of course, I am using a PIC Microcontroller in my experiments. The Microchip PIC Chips are different. Maybe you knew that. The software for PIC chips is MPLAB. Thanks for your comment. Have a nice day.
;free sample code. copy and paste. processor 16F684 include "p16f684.inc" ; Configuration settings __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF R1 EQU 0x20 ; outer loop counter R2 EQU 0x21 ; inner loop counter C1 EQU 0x22 ; specify file to store counter value BIT_COUNTER EQU 0x23 ; counter for bit testing ; Define connections #define SER_IN PORTA, 0 ; RA0 connected to 74HC595 SER_IN #define L_Clock PORTA, 1 ; RA1 connected to 74HC595 L_Clock #define Clock PORTA, 2 ; RA2 connected to 74HC595 Clock ; Main program start org 0x0000 goto Initialize ; Main program Initialize: ; Initialize ports bsf STATUS, RP0 ; Switch to Bank 1 clrf ANSEL ; Set all pins to digital clrf TRISA ; Set all pins of PORTA as output bcf STATUS, RP0 ; Switch to Bank 0 LOOP: MOVLW B'11101010' MOVWF C1 CLRF BIT_COUNTER BITTESTER: BCF SER_IN ; Clear SER_IN initially MOVF BIT_COUNTER, W BTFSC C1, 0 BSF SER_IN ; Set SER_IN if the corresponding bit in C1 is 1 CALL DELAY CALL SHIFT_CODE ; Shift C1 right by 1 bit RRF C1, F ; rotate right f through carry INCF BIT_COUNTER, F MOVLW 8 SUBWF BIT_COUNTER, W BTFSS STATUS, Z ; Check if BIT_COUNTER == 8 GOTO BITTESTER ; Repeat until 8 bits are tested BSF L_Clock ; L_CLOCK (PORTA, 1) sets or latches previously-sent 8 bits CALL DELAY BCF L_Clock ; L_CLOCK cleared back to low CALL DELAY GOTO LOOP SHIFT_CODE: ; shift register subroutine BSF Clock ; Clock pin (PORTA, 2), clocks in whatever serial input (PORTA, 0) is doing CALL DELAY BCF Clock CALL DELAY BCF SER_IN CALL DELAY RETLW 0 DELAY: MOVLW 0xFF MOVWF R1 AGAIN: MOVLW 0xFF MOVWF R2 HERE: NOP NOP DECFSZ R2, F GOTO HERE DECFSZ R1, F GOTO AGAIN RETLW 0 END ; Needed to end the program.
;free sample code, copy and paste processor 16F684 include "p16f684.inc" ; Configuration settings __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF R1 EQU 0x20 ; outer loop counter R2 EQU 0x21 ; inner loop counter C1 EQU 0X22 ; specify file to store counter value ; Define connections #define SER_IN PORTA, 0 ; RA0 connected to 74HC595 SER_IN #define L_Clock PORTA, 1 ; RA1 connected to 74HC595 L_Clock #define Clock PORTA, 2 ; RA2 connected to 74HC595 Clock ; Main program start org 0x0000 goto Initialize ; Main program Initialize: ; Initialize ports bsf STATUS, RP0 ; Switch to Bank 1 clrf ANSEL ; Set all pins to digital clrf TRISA ; Set all pins of PORTA as output bcf STATUS, RP0 ; Switch to Bank 0 LOOP MOVLW B'11101010' MOVWF C1 BITTESTER BTFSC C1, 0 BSF SER_IN ; PORTA, 0 (RA0) controls the serial input on the shift register CALL DELAY CALL SHIFT_CODE BTFSC C1, 1 BSF SER_IN CALL DELAY CALL SHIFT_CODE BTFSC C1, 2 BSF SER_IN CALL DELAY CALL SHIFT_CODE BTFSC C1, 3 BSF SER_IN CALL DELAY CALL SHIFT_CODE BTFSC C1, 4 BSF SER_IN CALL DELAY CALL SHIFT_CODE BTFSC C1, 5 BSF SER_IN CALL DELAY CALL SHIFT_CODE BTFSC C1, 6 BSF SER_IN CALL DELAY CALL SHIFT_CODE BTFSC C1, 7 BSF SER_IN CALL DELAY CALL SHIFT_CODE BSF L_Clock ; L_CLOCK (PORTA, 1) sets or latches previously-sent 8 bits CALL DELAY BCF L_Clock ; L_CLOCK cleared back to low CALL DELAY GOTO LOOP SHIFT_CODE ; shift register subroutine BSF Clock ; Clock pin (PORTA, 2), clocks in whatever serial input (PORTA, 0) is doing CALL DELAY BCF Clock CALL DELAY BCF SER_IN CALL DELAY RETLW 0 DELAY MOVLW 0xFF MOVWF R1 AGAIN MOVLW 0xFF MOVWF R2 HERE NOP NOP DECFSZ R2, F GOTO HERE DECFSZ R1, F GOTO AGAIN RETLW 0 END ; Needed to end the program.
Timestamp: 7:20 is the Pin Set-up and Configuration The Reset pin has to be tied to high (5v), although a low signal resets it. The O/E (output enabled) pin should be tied to ground. That is, if you want to see the LEDs. 11:36 This is an error. The clock pin is set with a high signal. The L_Clock pin is set with a high signal. I also made a video where I program this shift register with a PIC16F684 microcontroller. Click here: ua-cam.com/video/f1AVdkLLIH0/v-deo.html
I liked you spoke the truth. Thanks
Rakipsiz Gazetesi: İyi günler, güzel yayınlar diliyoruz. 😊
Hi nerds! I expect you enjoyed watching my last video. You’re welcome. I’ll reward you with another video. Today. I am further discussing the block diagram of the PIC16F684. It’s really important that you subscribe. So, go ahead and do that. Now, please! Alright, so let’s take a look at the PIC16F684 block diagram. In the PIC16F684 microcontroller, the program bus is an internal pathway used to transfer program instructions and data between different components within the microcontroller. Specifically, it connects the program memory (where the program instructions are stored) to the CPU (Central Processing Unit). Here's a breakdown of its role: Fetching Instructions: The program bus is used by the CPU to fetch instructions from the program memory. These instructions are stored in the program memory as a sequence of binary codes. Instruction Execution: Once an instruction is fetched, the CPU decodes and executes it. This process may involve reading or writing data to/from other parts of the microcontroller, such as the data memory or I/O ports. Addressing: The program counter (PC) in the CPU holds the address of the next instruction to be fetched from the program memory. This address is sent over the program bus to access the correct memory location. Transfer of Data: In addition to fetching instructions, the program bus may also be involved in transferring data that is part of the program instructions, such as immediate values or addresses for branching operations. In the block diagram of the PIC16F684, the program bus is typically depicted as a set of lines connecting the program memory to the CPU, indicating the flow of instruction codes from the memory to the CPU for execution. This bus is crucial for the operation of the microcontroller, as it ensures the proper sequence and execution of the stored program. Alright, let’s talk about what the "Instruction Reg" is. You can see the “instruction red” shown in the PIC16F684 block diagram. The "Instruction Reg" (Instruction Register) shown in the PIC16F684 block diagram is a critical component in the microcontroller's CPU. Its primary function is to temporarily hold the current instruction fetched from the program memory before it is decoded and executed by the CPU. Here's a detailed explanation of its role: Fetching: The instruction register receives the instruction from the program memory via the program bus. This instruction is fetched based on the address specified by the program counter (PC). Holding: Once the instruction is fetched, it is stored in the instruction register. This temporary holding allows the CPU to decode and execute the instruction while the next instruction is being fetched from the program memory. Decoding: The instruction register contents are decoded by the instruction decoder, which interprets the binary code of the instruction to determine the required operation. Executing: After decoding, the CPU executes the instruction. This may involve various operations such as arithmetic calculations, data transfer, logic operations, or control operations. In summary, the Instruction Register in the PIC16F684 block diagram is essential for holding and processing each instruction fetched from the program memory, enabling the CPU to perform its tasks sequentially and efficiently. Basically, the “instruction register” is a thing. It holds the instruction for processing. Next, as you were looking at the PIC16F684 block diagram, you may have asked yourself, what is the "addr mux"? I’m glad you asked, because I have an answer. You’re welcome. In the PIC16F684 microcontroller, the "addr mux" refers to the address multiplexer. This component plays a crucial role in managing the addresses sent to the program memory and other memory components within the microcontroller. Here’s a detailed explanation of its function: Address Selection: The address multiplexer (addr mux) selects between different sources of addresses that need to be sent to the program memory or other memory components. These sources typically include the program counter (PC), which provides the address of the next instruction to be fetched, and potentially other address sources for special operations like interrupts or jumps. Program Counter (PC): The addr mux typically selects the address from the program counter during the normal execution flow, allowing the sequential fetching of instructions from the program memory. Interrupts and Jumps: When an interrupt occurs or a jump instruction is executed, the addr mux switches to select the new address provided by the interrupt vector or jump instruction, redirecting the execution flow to the appropriate memory location. Efficiency and Control: By using an addr mux, the microcontroller efficiently manages the flow of instruction addresses, ensuring that the correct instruction is fetched at the right time. This is crucial for the microcontroller’s operation, particularly in handling sequential execution, branching, and interrupts. In summary, the "addr mux" in the PIC16F684 block diagram is an address multiplexer that selects the appropriate address source (usually between the program counter and other sources) to access the correct memory location, enabling proper instruction fetching and execution. Alright, I am going to end this video here for now. I want to continue to examine the PIC16F684 block diagram. However, to fully explain my next topic, it requires an explanation of indirect addressing. I’ll cover than in my next video. Thanks for watching. Stay tuned. And, please subscribe.
The PIC16F684 is an 8-bit microcontroller from Microchip Technology, a company renowned for its extensive range of microcontrollers and microcontroller peripherals. This particular microcontroller is part of the PIC16F family, known for their versatility, affordability, and robustness in various applications, from simple to moderately complex systems. Key Features Core and Performance: CPU Core: The PIC16F684 utilizes the PIC16 instruction set architecture, which includes a reduced instruction set computing (RISC) architecture. This architecture features 35 instructions, making it relatively simple to learn and use. Clock Speed: It operates at a maximum clock speed of 20 MHz. The clock frequency can be derived from an internal oscillator or an external clock source, providing flexibility for different applications. Operating Voltage: It supports a wide operating voltage range from 2.0V to 5.5V, making it suitable for battery-operated devices and other low-power applications. Memory: Program Memory: The PIC16F684 includes 7 Kbytes of Flash memory, which is used to store the user’s program. Flash memory allows for easy program updates and reprogramming. Data Memory: It has 256 bytes of RAM for temporary data storage during program execution. EEPROM: There are 256 bytes of EEPROM for non-volatile data storage, which is useful for saving configurations or states that must be retained after power loss. Peripherals and I/O: I/O Ports: The microcontroller has 12 general-purpose input/output (GPIO) pins. These can be individually configured as either inputs or outputs, allowing for flexible interfacing with other components. Analog-to-Digital Converter (ADC): It features an 8-bit ADC with multiple input channels, enabling the conversion of analog signals to digital values for processing. Comparators: There are two analog comparators available, which can be used for comparing voltage levels. Timers: The PIC16F684 includes multiple timers (Timer0, Timer1, Timer2) that are useful for timing operations, generating delays, and creating pulse-width modulation (PWM) signals. PWM: It also supports PWM output, which is commonly used in motor control, LED dimming, and other applications requiring variable duty cycle signals. Communication: USART/Serial Communication: The microcontroller supports asynchronous serial communication via the Universal Synchronous Asynchronous Receiver Transmitter (USART) module. This feature is vital for communication with other microcontrollers, computers, and serial devices. I2C and SPI: Although not directly supported by hardware modules in the PIC16F684, I2C and SPI communication can be implemented through software, allowing communication with a variety of peripherals and sensors. Special Features: Watchdog Timer: The watchdog timer helps recover from software malfunctions by resetting the microcontroller if the program hangs or enters an infinite loop. Brown-Out Reset: This feature ensures the microcontroller resets when the supply voltage drops below a certain threshold, protecting against erratic operation due to low voltage. In-Circuit Serial Programming (ICSP): ICSP allows the microcontroller to be programmed while installed in the target circuit, facilitating easy updates and debugging. Applications The PIC16F684’s diverse features make it suitable for a wide range of applications. Some common use cases include: Embedded Systems: It is often used in embedded systems for control applications, such as home automation, industrial control, and consumer electronics. Sensor Interfaces: With its ADC and digital I/O, the PIC16F684 can interface with various sensors, making it suitable for data acquisition systems. Motor Control: The PWM capabilities and comparators make it useful in motor control applications, such as controlling the speed and direction of DC motors. Battery-Powered Devices: Its low-power operation and wide voltage range make it ideal for portable, battery-powered devices like remote controls and handheld gadgets. Automotive: It can be used in automotive applications for tasks like sensor interfacing, lighting control, and small-scale data logging. Development Tools Microchip Technology provides a range of development tools to facilitate programming and debugging the PIC16F684: MPLAB X Integrated Development Environment (IDE): This free IDE supports the development of applications for the PIC16F684. It provides features like code editing, debugging, and simulation. MPLAB XC8 Compiler: A C compiler for the PIC family of microcontrollers, allowing for the development of code in the C programming language. PICkit 4: A programmer/debugger tool that supports in-circuit programming and debugging of the PIC16F684. It connects to the microcontroller via the ICSP interface. Programming and Development Programming the PIC16F684 typically involves writing code in either assembly language or C. Assembly language offers fine-grained control over the hardware but requires detailed knowledge of the microcontroller’s architecture. C, on the other hand, is more abstract and user-friendly, making it the preferred choice for most developers. Conclusion The PIC16F684 microcontroller is a versatile and robust device suitable for a wide range of applications. Its combination of features, including a RISC architecture, flexible I/O, ADC, timers, and communication interfaces, make it a popular choice for both hobbyists and professionals. With comprehensive development tools and a supportive community, the PIC16F684 continues to be a reliable choice for designing and implementing embedded systems. Whether you're building a simple sensor interface or a complex control system, the PIC16F684 offers the functionality and performance needed to bring your project to life.
Nice project
You should read: "The Quintessential PIC® Microcontroller" by Sid Katzen. The best book ever about PIC's !!! And PIC10F200 doesn't have any INTCON register to control interrupts from Timer0. That is madness!
I am playing using it but the music stops midway, like a few seconds in. Any fix for this?
Tanks from Argentina
the default is 5 volts for the target device but it gives a error (won't work) so I always use 4.87 volts and it works every time.
CRAP!
I look forward to watching some of your content. Let me know when you post your first video. I'll let you know if your content is crap.
Is your profile picture A.I, generated or are you really that handsome?
Here's a copy of my header: "config.h" // This is a guard condition so that contents of this file are not included // more than once. #ifndef XC_HEADER_TEMPLATE_H #define XC_HEADER_TEMPLATE_H // PIC10F200 Configuration Bit Settings // 'C' source line config statements // CONFIG #pragma config WDTE = OFF // Watchdog Timer (WDT disabled) #pragma config CP = OFF // Code Protect (Code protection off) #pragma config MCLRE = ON // Master Clear Enable (GP3/MCLR pin function is MCLR) // #pragma config statements should precede project file includes. // Use project enums instead of #define for ON and OFF. #define _XTAL_FREQ 4000000 #include <xc.h> #endif /* XC_HEADER_TEMPLATE_H */
Maybe you are a beginner but your video is very good in bringing the information and issues to expect, working with PIC10F200. I saw somewhere that the PIC10F200 can only be written once, it's a ROM memory not a EPROM, can anybody help me please and confirm or not? Thank you
You can write to it over and over. (Some of the commercial products that are one-time programmable.)
Thank you for your reply @@2bit661
// sample code, copy and paste, have fun! #include <Arduino.h> void setup() { Serial.begin(9600); // Initialize serial communication } void loop() { // Input metrics float peRatio, debtToEquityRatio, profitMargin; // Prompt user for input using Serial Monitor Serial.println("Enter the P/E Ratio:"); while (!Serial.available()) { // Wait for user input } peRatio = Serial.parseFloat(); Serial.println("Enter the Debt to Equity Ratio:"); while (!Serial.available()) { // Wait for user input } debtToEquityRatio = Serial.parseFloat(); Serial.println("Enter the Profit Margin:"); while (!Serial.available()) { // Wait for user input } profitMargin = Serial.parseFloat(); // Define scoring thresholds float peThresholdLow = 10.0; float peThresholdMedium = 15.0; float debtEquityThresholdLow = 0.5; float debtEquityThresholdMedium = 1.0; float profitMarginThresholdHigh = 15.0; float profitMarginThresholdMedium = 10.0; // Initialize scores int peScore = 0; int debtEquityScore = 0; int profitMarginScore = 0; // Scoring for P/E Ratio if (peRatio < peThresholdLow) { peScore = 3; } else if (peRatio < peThresholdMedium) { peScore = 2; } else { peScore = 1; } // Scoring for Debt to Equity Ratio if (debtToEquityRatio < debtEquityThresholdLow) { debtEquityScore = 3; } else if (debtToEquityRatio < debtEquityThresholdMedium) { debtEquityScore = 2; } else { debtEquityScore = 1; } // Scoring for Profit Margin if (profitMargin > profitMarginThresholdHigh) { profitMarginScore = 3; } else if (profitMargin > profitMarginThresholdMedium) { profitMarginScore = 2; } else { profitMarginScore = 1; } // Calculate overall stock score int overallScore = peScore + debtEquityScore + profitMarginScore; // Display individual scores and overall score Serial.println(" Individual Scores:"); Serial.print("P/E Ratio Score: "); Serial.println(peScore); Serial.print("Debt to Equity Ratio Score: "); Serial.println(debtEquityScore); Serial.print("Profit Margin Score: "); Serial.println(profitMarginScore); Serial.print(" Overall Stock Score: "); Serial.println(overallScore); // Wait for the next input delay(5000); }