• Reading 80C52 Port 3 Bits

    03/26/2024 at 16:16 0 comments

    Introduction: 

    While BASIC-52 allows you to access Port 1 bits directly through BASIC, it does not allow direct access of the Port 3 bits available on many of the boards and modules

    Background: Port 3 is an 8 bit bi-directional I/O port with internal pullups.

    •                         Port Pin                   Alternaye Function
    •                            P3.0                      RXD (serial input port)
    •                            P3.1                      TXD (serial output port)
    •                            P3.2                      *INT0 (external interrupt 0)
    •                            P3.3                      *INT1 (external interrupt 1)
    •                            P3.4                      T0 (timer 0 external input)
    •                            P3.5                      T1 (timer 1 external input)
    •                            P3.6                      *WR (external Data Memory write strobe)
    •                            P3.7                       RD (external Data Memory read strobe)

    Program Listing:

    Example 1: Waiting for a bit to be set or cleared

    BASIC-52 program . . . CALL xxxxh

    Assembly routine

    xxxxh Label1: JB P3.x, Label1 ;Loop until bit is set RET ;Return to BASIC program

    or

    xxxxh Label1: JNB P3.x,Label1 ;Loop until bit is cleared RET ;Return to BASIC program

    Example 2: Return the state of a bit to BASIC-52

    BASIC-52 program . . . CALL xxxxh

    Assembly routine

    Xxxxh Label1: JB P3.x, B_SET ;Test the bit, jump if set B_CLR: MOV 20h, #0 ;Store 0 if cleared RET

    B_SET: MOV 20h, #1 ;Store 1 if set RET

    Once you are back in the BASIC program use the following line to read what was stored:

    IF DBY(20h)=0 THEN PRINT "P3.x = Low" ELSE PRINT "P3.x = High"

    This page is based on Micromint inc's AN101 Dated: 7/28/99

  • Controlling 80C52 Port 1 Bits with Assembly Language Calls

    03/26/2024 at 16:10 0 comments

    Introduction: 

    Although the Port 1 bits can be controlled directly through BASIC using the PORT1 command, sometimes its easier to use assembly language calls. This method allows the individual bits to be changed instead of the whole port.

    Background: 

    The following table indicates the addresses for the Port 1 bits:

    • P1.0 = 90h P1.4 = 94h P1.1 = 91h P1.5 = 95h 
    • P1.2 = 92h P1.6 = 96h P1.3 = 93h P1.7 = 97h

    If only a few of the bits are being controlled then the easiest way to implement this is by storing the machine code using data statements. The code to set, clear, or toggle a bit takes three bytes of memory (command, address, return).

    The machine code commands are used as follows: 

    NOTE: Assignments must begin with an integer, otherwise the processor will interpret them as a variable.

    0D2h = set bit 0C2h = clear bit 0B2h = toggle bit (if set, clear it or if cleared, set it)

    Program Listing: The sample program below shows how the commands are stored and then called:

    10 DATA 0D2h, 94h, 22h : REM code to set bit 4 of port 1 
    20 DATA 0C2h, 94h, 22h : REM code to clear bit 4 of port 1  
    30 DATA 0B2h, 90h, 22h : REM code to toggle bit 0 of port 1 
    40 FOR ADR = 4000h to 4008h : REM store the codes -this must be a free area of RAM!
    50 READ DT 
    60 XBY(ADR) = DT 
    70 NEXT ADR 
    80 REM all commands are now stored in RAM 
    200 CALL 4000h : REM set bit 3 of port 1 
    210 CALL 4003h : REM clear bit 3 of port 1 
    220 CALL 4006h : REM toggle bit 0 of port 1 
    230 GOTO 200 : REM continuous loop through the three commands

     This page is based on Micromint inc's application note AN103 Dated: 5/26/98

  • Weird PS/2 mouse

    12/31/2022 at 18:07 1 comment

    What is PS/2?

    The PS/2 (Personal System/2) port, also referred to as the mouse port or keyboard port, was developed by IBM. It is used to connect a computer mouse or keyboard to an IBM compatible computer. The PS/2 port is a mini DIN plug containing six pins and is still sometimes found on all IBM compatible computers. 

    Came across a PS/2 mouse.  

    The mouse controller is PIC16C58!

    Touch or pressure sensor covered by US5431064A patent 

    A pressure sensitive transducer array in which a plurality of transducers are connected in series and in parallel with one another. In one embodiment, a resistive layer is formed from carbon or silver ink on a polyester film. A plurality of conductive shunt elements having greater conductivity than the resistive layer is formed on a second polyester film. The films are placed adjacent to one another with the shunt elements contacting the resistive layer. Voltage is applied across the resistive layer and pressure is applied thereto. As the pressure increases, the number of current paths set up through contact points on the shunt elements increase thereby decreasing the resistance across the resistive layer and increasing current flow. In another embodiment a plurality of plate elements are contained in a plane on one side of a dielectric layer. A plurality of plate elements are contained in a plane on the other side of the dielectric layer. As the layer is pushed together responsive to force applied, total capacitance as measured across the planes of plate elements varies.

    Sensor bottom view 

    https://patents.google.com/patent/US5431064