Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC16F84A INTERFACE WITH MSM6242BRS(PLS HELP ME)

Status
Not open for further replies.

Jay Duluguin

New Member
I already bought PIC16F84A and interface it with MSM6242BRS.Do you think they are compatible with eah other. What I only need to know about PIC is the required starting/basic programming of PIC, Loading of ADDRESS data into MSM6242BRS(DIRECT BUS CONNECTED REAL TIME CLOCK/CALENDAR)thru PIC, reading data registers from MSM6242BRS through PIC16F84A & interrrupts into both PIC AND MSM6242BRS .I already have the PIC C COMPILER in programming PIC.

PLEASE HELP ME!!!!!!!!!!!!!!!!!!
 
They are compatible, I am assuming you are going to power them from the same 5V supply.

You have to connect the address inputs A0-A3 to your PIC outputs and the Data to your inputs.

If you read the data sheet you can see that by choosing a register with the A0-A3 you can obtain the data at your Data pins. Check the data rehister table on page 3 of the **broken link removed**

Ivancho
 
PIC16F84A INTERFACE WITH MSM6242BRS

DESCRIPTION
The MSM6242B is a silicon gate CMOS Real
Time Clock/Calendar for use in direct bus-
connection Microprocessor/Microcomputer
applications.An on-chip 32.768 kHz crystal
oscillator time base is divided to provide ad-
dressable 4-bit I/O data for SECONDS,MIN-
UTES,HOURS,DAY OF WEEK,DATE,
MONTH and YEAR.Data access is controlled
by 4-bit address,chip selects (CS0 ,CS1),
WRITE ,READ ,and ALE.Control Registers
D,E nd F provide for 30 SECOND error
adjustment,INTERRUPT REQUEST (IRQ
FLAG)and BUSY status bits,clock STOP,
HOLD,nd RESET FLAG bits,4 selectable
INTERRUPTS rates are available at the STD.P
(STANDARD PULSE)output utilizing Con-
trol Register inputs T0,T1 and the ITRPT/
STND (INTERRUPT/STANDARD).Mask-
ing of the interrupt output (STD.P)can be
accomplished via the MASK bit.The
MSM6242B can operate in a 12/24 hour for-
mat and Leap Year timing is automatic.
The MSM6242B normally operates from 5 V
±10%supply at –40 to +85 °C.Battery backup
operation down to 2.0 V allows continuation
of time keeping when main power is off.The
MSM6242B is offered in a 18-pin plastic DIP
and a 24-pin plastic Small Outline package.
FEATURES
DIRECT MICROPROCESSOR/MICROCONTROLLER BUS CONNECTION
TIME MONTH DATE YEAR DAY OF WEEK
23:59:59 12 31 80 7
•4-bit data bus
•4-bit address bus
•READ ,WRITE ,ALE and CHIP SELECT
INPUTS
•Status registers – IRQ and BUSY
•Selectable interrupt outputs – 1//64
second,1 second,1 minute,1 hour
•Interrupt masking
•32.768 kHz crystal controlled operation
•12/24 hour format
•Auto leap year
•±30 second error correction
•Single 5 V supply
•Battery backup down to V DD =2.0 V
•Low power dissipation:
20 µW max at V DD =2 V
150 µW max at V DD =5 V
•Package:18-pin plastic DIP (DIP18-P-300-2.54)(MSM6242BRS)
24-pin plastic SOP (SOP24-P-430-1.27-K)(MSM6242BGS-K)
MSM6242B
DIRECT BUS CONNECTED CMOS REAL TIME CLOCK/CALENDAR


ATTACHED HEREWITH IS THE PDF FILE OF MSM6242BRS.
 
Connect the PIC to the MSM using PICA0-A3 as the address control pins.
You will need to set PORTA to all outputs. Use PIC B0-B3 as inputs to read the data from MSM.
You will need to control the RD and WR pints of the MSM so set PortB4,5 to RD and WR and use these to control reading and writing. Also wire CS to high because you will always be using the chip.


You will most likely be running your pic at 4MHz which is alot faster then the 38.7 KHz of the timer chip so you will need to wait for the write cycles to complete before reading the data off of PORTB.

Suppose you want to read the ones position of the seconds register (S1), you will need to write 0x00 to the PORTA and then initiate a read cycle by setting cycling RD from high to low. (this means that you should initiate RD=1). Set PORTB4 (bcf PORTB, 4 in assembler) which will cause the MSM to write the value in S1 to D0-D4. Once the data is written, you can read it in by doing reading the data on PORTA.
; read porta
movf PORTB, DATA
; get rid of high bit
movlw 0x0f
andwf DATA, f
; now data holds the value passed in from MSM so set RD back to 1
bsf PORTB, 4


You have to do the andwf because this will clear out the unused bits that are garbage. Once this is complete you can read in the ext part of the seconds integer.

movlw 0x01
mowf PORTA ; set the address to s10
bcf PORTB, 4 ; initiate a read
movf PORTB, DATA2; read from portb
movlw 0x0f
andwf DATA2, f ; get rid of garbage

; now DATA2*10+DATA = seconds
rlf DATA2
rlf w
rlf w
movwf SEC ;rotate left 3
rlf DATA2
addwf SEC, f; rotate left1 store in SEC
; shortcut for multiply by ten is shift left 4 + shift left 2
; SEC now contains the S10 part of the second and only needs the S1 part to be added in
movf DATA
addwf SEC, f
; now second has the value for seconds. YOu can do the same for all other registers.
Depending on what speed you are running your PIC you will most likely have to sleep for sometime until your data has been written to D0-D3 of the MSM.
 
PIC16F84A INTERFACE WITH MSM6242BRS

Good day Aevans17 :D

I really thanks and appreciate you for the reply that you give.Could you also give us the whole 'algorithm' about the program from the start till the end(e.g., initialization of ports,clearing of ports).By the way , I have no idea about the assembly programming in PIC uC and that is actually the real problem here.It is also a grateful if you also could give us the ASM source code of the program. But it is still O.K. even if you could only give the algorithm.

Moreover Sir, I thought the read and write pins from MSM is a gate which is actually perform by the PIC to activate this pin from its embedded program execution but has also external connection from PIC inputs say touch switches inorder to 'set' the exact time just like in a digital watches where there is a tiny push button to set the correct time.Or it is just that I misunderstand the phrase:

[
Suppose you want to read the ones position of the seconds register (S1), you will need to write 0x00 to the PORTA and then initiate a read cycle by setting cycling RD from high to low. (this means that you should initiate RD=1). Set PORTB4 (bcf PORTB, 4 in assembler) which will cause the MSM to write the value in S1 to D0-D4. Once the data is written, you can read it in by doing reading the data on PORTA. ]

What I have in my mind is that if we send data (high input or rising edge) into pin WR of MSM we can send data into pin D0-D3 of MSM ,from the output pins of PIC with which they are directly connected to each other.

I hope you could correct what is actually the transmission of data between the PIC and microcontroller.

Hoping for your reply and guidance.

GOD BLESS.

j_f_duluguin
 
To write to the MSM you will want to call this function:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;Variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
STATUS equ 0x03
RP0 equ 0x05
PORTA equ 0x05
PORTB equ 0x06
TRISA equ 0x85
TRISB equ 0x86
VALUE equ 0x0f
ADDR equ 0x10

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; this configures PORTB and PORTA for direction
; a one is input, while a zero is output
; set PORTB for half inputs/half outputs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
bsf STATUS,RP0 ; set RP0 for RAM page 1
movlw 0x00; PORTA all outputs
movwf TRISA
movlw 0x0f; PortB half in half out
movwf TRISB
bcf STATUS,RP0; set RP0 for RAM page 0

; connect PORTB pins 0-3 to D0-D4 of MSM
; connect PORTB pin4 to RD pin of msm
; connect PORTB pin5 to WR pin of msm
; connect all PORTA to Address pins

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SendValue
;; Sends the integer stored in VALUE
;; to address ADDR
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SendValue: movf VALUE, 0 ; write the value into working register w
movwf PORTB ; set that value to portb
movf ADDR, 0 ; move the address value into w
movwf PORTA ; set the address to port a
bsf PORTB, 5 ; tell MSM that we are writing to it
return

;Example of how to call the function:
;Say you want to put a 9 in the S1 register of MSM
;...
movlw 0x09
movwf VALUE
movlw 0x01; Address of register S1 is 0x01
movwf ADDR
call SendValue
;...

You can get the rest of the register addresses from the documentation on the MSM chip. Put the SendValue function at the bottom of your code and it will work. Also, make sure to include the variable declarations from above.
 
NO problem, glad I could help. These types of forums are great!!! I was just here asking my own questions a few weeks ago, and now I am returning the favor!! Let me know if you need anything else.
 
Error Correction:

from my earlier post:
;Example of how to call the function:
;Say you want to put a 9 in the S1 register of MSM
;...
movlw 0x09
movwf VALUE
movlw 0x01; Address of register S1 is 0x01
movwf ADDR
call SendValue
;...


This is wrong, the S1 register is at address 0x00, and the S10 register is at 0x01. This means that the sample above would write the value 9 in into the 10's digit of seconds which would be invalid because seconds only go from 0 to 59, not 90. Sorry for this. Here is an update:

;Example of how to call the function:
;Say you want to put a 3 in the S10 register of MSM
;...
movlw 0x03
movwf VALUE
movlw 0x01; Address of register S1 is 0x01
movwf ADDR
call SendValue
;...

Anyway you get the idea.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top