Jump to content
ELFORUM - Forumul electronistilor
Guest chiar_eu

hex from .bas please

Recommended Posts

Guest chiar_eu

' *****************************************************************************

' * Title : EEPROM programmer.bas

' * Last Updated : 05.03.2006

' * Target device: At90s2313, 24C32

' * Author : http://www.avrprojects.net

' * Program code : BASCOM-AVR

' * Hardware req. :

' * Description :

' * This application reads and writes one page at a time to an 24c32 EEPROM connected to an

' * AT2313 microcontroller.

' *****************************************************************************

Dim D_w As Byte , D_r As Byte , Adress As Byte , E_adr As Byte , E_dat As Byte , I As Byte , Count As Byte

 

Dim Rw As String * 1 , Datastr As String * 32

Dim E_data(16) As Byte

 

Config Scl = Portb.0 'assign the SCl line to PORTD.0

Config Sda = Portb.1 'assign the SDA line to PORTD.1

 

'Declare Sub Byteread

'Declare Sub Bytewrite

Declare Sub Pagewrite

Declare Sub Pageread

 

Main:

Do

Input "®ead page / (W)rite page?" , Rw

If Rw = "R" Or Rw = "r" Then Goto Read_eeprom

If Rw = "W" Or Rw = "w" Then Goto Write_eeprom

Loop

End 'end program

 

Read_eeprom:

Do

Input "Read EEPROM page :" , Adress

Print Adress ; ":" ;

E_adr = Adress * 16

Call Pageread

For I = 1 To 16

Print E_data(i) ; ",";

Next I

Print

Loop

 

Write_eeprom:

Do

Input "Write EEPROM page :" , Adress

For I = 1 To 16

Input "Input byte ";i;" :" , E_data(i)

Next I

Print Adress ; ":"

For I = 1 To 16

Print E_data(i) ; ",";

Next I

 

E_adr = Adress * 16

Call Pagewrite

 

Print

 

Loop

 

'********** page write to EEPROM ***************************************************

Sub Pagewrite

I2cstart 'generate start

I2cwbyte &B1010_0000 'send device address

I2cwbyte &H00 'H adress of EEPROM

I2cwbyte &H00 'L adress of EEPROM

For I = 1 To 16

D_w = E_data(i)

I2cwbyte D_w 'data to EEPROM

Next Adress

I2cstop 'stop condition

Waitms 10

End Sub Pagewrite

 

'********** page read from EEPROM **************************************************

Sub Pageread

I2cstart 'generate start

I2cwbyte &B1010_0000 'send device adsress

I2cwbyte &H00 'H address of EEPROM

I2cwbyte E_adr 'L address of EEPROM

I2cstart 'repeated start

I2cwbyte &B1010_0001 'slave address (read)

For I = 1 To 16

I2crbyte D_r , Ack 'data to EEPROM

E_data(i) = D_r

Next I

I2crbyte D_r , Nack 'read byte from EEPROM

I2cstop

End Sub Pageread 'generate stop

 

 

'********** byte write to EEPROM ***************************************************

'Sub Bytewrite

'I2cstart 'generate start

'I2cwbyte &B1010_0000 'send device address

'I2cwbyte 0 'H adress of EEPROM

'I2cwbyte 0 'L adress of EEPROM

'I2cwbyte D_w 'data to EEPROM

'I2cstop 'stop condition

'Waitms 10

'End Sub

 

 

'********** byte read from EEPROM **************************************************

'Sub Byteread

'I2cstart 'generate start

'I2cwbyte &B1010_0000 'send device adsress

'I2cwbyte &H00 'H address of EEPROM

'I2cwbyte &H00 'L address of EEPROM

'I2cstart 'repeated start

'I2cwbyte &B1010_0001 'slave address (read)

'I2crbyte D_r , Nack 'read byte from EEPROM

' I2cstop 'generate stop

'End Sub Byteread

Link to comment
Share on other sites

Guest Vasile

BASCOM AVR ii zice la Programul pe care trebuie sa-l folosestiai erori in programError : 1 Line : 25 Unknown statement [MAIN]Error : 1 Line : 33 Unknown statement [READ_EEPROM]Error : 1 Line : 45 Unknown statement [WRITE_EEPROM]

Link to comment
Share on other sites

Guest musaraf

Se pare ca problema era cu ceva spatii dupa label-uri (Main:, Read_eeprom:, Write_eeprom:), daca se sterg compileaza.Si i-am mai pus un $regfile = "2313DEF.dat" la inceput. Compilat si cu o varianta mai veche de Bascom (cu aia noua nu stiu daca alege corect chipul).HEX-urile si BAS-ul a trebuit sa le pun ca DOC, ca nu ma lasa altfel.Sper sa-ti mearga.

Link to comment
Share on other sites

Guest chiar_eu

am citit pedefeul de modificare de la at90s2313 la atinny2313 dar nu am brighidit care-i shmenul. Poti Vasile sa-mi compilezi aceeasi traba pentru attinny2313?Berea vine la B1 de la Iri ...varu-miu! :partyman:

Link to comment
Share on other sites

Guest chiar_eu

softul ala nu face nimic altceva decit sa scrie si sa citeasca dintr-un eeprom 24c32 conectat la pini PORTD.0 si PORTD.1ca sa se conecteze cu o interfata mai trebuie lucrat "putin" la soft

pai nu am nevoie musai de interfata aia...am inteles ca ea doar are prememorate niste linii cu cod cunoscut pe care le incarca in locul celor necunoscute...eu vreau doar sa mearga aplicatia de i2c reader writer de la avr projects, dar deocamdata nu pot accesa aplicatia lor de hyperterminal...da o eroare...This is a terminal program that you can use for serial communication with you microcontrollers. It is written in Visual Basic.Net. The program is simple to use. To use the program a file called port.dll needs to be placed in the same folder as the AVR Terminal.exe file. All the files can be downloaded at the bottom of this page. Within the program the Com ports 1 to 8 can be choosen and also the baud rate from 300 to 19200 baud. The screen is divided in 2 areas, one for the input and one for the output. If you enter text in the input area and push [ENTER] the input area will automatically be cleared.http://www.avrprojects.net/articles.php?lng=en&pg=68
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.Terms of Use si Guidelines