Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

EEPROM 93C HELP
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
kimmi

Moderator



Joined: 24 Feb 2006
Posts: 1922
Location: Denmark

denmark.gif
PostPosted: Fri Feb 10, 2017 6:53 pm    Post subject: Reply with quote

An update about 93C46

I used AT93C46D-PU

and here is the working code for 64x16 !!!

Code:
$regfile = "m48def.dat"
$crystal = 8000000
$hwstack = 32
$swstack = 32
$framesize = 32

 'AT93C46D-PU >        '64x16  PIN ORG to VCC * PIN 8 VCC * PIN 5 GND

Cs Alias Portc.0                                            '93c46 pin 1 CS
Config Portc.0 = Output
Pin_in Alias Pinc.3                                         '93c46 pin 4 DO
Config Portc.3 = Input
Pin_out Alias Portc.2                                       '93c46 pin 3 DI
Config Portc.2 = Output
Sck Alias Portc.1                                           '93c46 pin 2 SK
Config Portc.1 = Output

Dim My_data As Word , Got_data As Word , Read_enable As Word
Dim My_93c46 As Long

Declare Sub Write_data_93c46(byval 93c_addr As Byte , Byval 93c_data_in As Word)
Declare Sub Read_data_93c46(byval 93c_addr As Byte )
Declare Sub Setup_93c46()
Cs = 0

Const R_93c46 = &B110                                       'read
Const W_93c46 = &B101                                       'write

Read_enable = &B1001100000000000                            ' Enable serial EEPROM    (EWEN):

Call Setup_93c46()                                          'allways do this after power on !!!!
Waitms 50

' main
Do
      ' write data to 93c46
      ' Write_data_93c46(address , data)
   Call Write_data_93c46(50 , 2516)                      'sample address 50  data 2516

      ' read data from 93c46
      ' Read_data_93c46(address)
   Call Read_data_93c46(50)                              'sample read address 50
   '  data read in VAR Got_data  
Wait 5
Loop
End

' Enable serial EEPROM   9bits
Sub Setup_93c46()
   Cs = 1
   Shiftout Pin_out , Sck , Read_enable , 1 , 9             '  write enable command
   Cs = 0
   Waitms 50
End Sub

' write address and data
Sub Write_data_93c46(byval 93c_addr As Byte , Byval 93c_data_in As Word)
   My_93c46 = W_93c46
   Shift My_93c46 , Left , 6
   My_93c46 = My_93c46 + 93c_addr
   Shift My_93c46 , Left , 16
   My_93c46 = My_93c46 + 93c_data_in
   Shift My_93c46 , Left , 7
   Cs = 1
   Shiftout Pin_out , Sck , My_93c46 , 1 , 25               ' address and data
   Cs = 0
   Waitms 10
End Sub

'read address put it in got_data
Sub Read_data_93c46(byval 93c_addr As Byte )
   My_93c46 = R_93c46
   Shift My_93c46 , Left , 6
   My_93c46 = My_93c46 + 93c_addr
   Shift My_93c46 , Left , 23
   Cs = 1
   Shiftout Pin_out , Sck , My_93c46 , 1 , 9                '  address
   Shiftin Pin_in , Sck , Got_data , 1 , 16                 ' read data
   Cs = 0
   waitms 10
End Sub

_________________
/ Kim
Back to top
View user's profile Visit poster's website MSN Messenger
jeezywonder

Bascom Member



Joined: 19 Jan 2017
Posts: 34
Location: Russia, Vladivostok

russia.gif
PostPosted: Sat Feb 11, 2017 10:27 am    Post subject: Reply with quote

Thank you kimmi, will check it on monday Smile
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum