Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

want to transfer eeprom via UART to PC... Problem with binar

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
boeseturbo

Bascom Member



Joined: 23 Jul 2007
Posts: 31

blank.gif
PostPosted: Tue Mar 28, 2017 4:51 pm    Post subject: want to transfer eeprom via UART to PC... Problem with binar Reply with quote

Hi friends,


I want to transfer eeprom from avr to pc. I tried to made it via binary format (printbin var)... That runs pretty nice, but When eeprom value is zero, the avr didnt transfer a byte to pc.
That is my problem which I have.

I want to transfer 128 byte, and when one value is zero, it is missing in data transfer. Has anybody an Idea?

Code:

do
  uart=inkey(#1)

  if uart =200 then
     csum=0
     for temp_byte = 1 to 128
     Readeeprom bblock , temp_byte
     printbin #1, bblock
     csum=csum+bblock
     next temp_byte
     printbin #1,csum
  end if
loop
 


kind regards

Jan

(BASCOM-AVR version : 2.0.7.8 )
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5061
Location: Holland

blank.gif
PostPosted: Tue Mar 28, 2017 7:14 pm    Post subject: Reply with quote

printbin will also send a zero. it is simple to check with the simulator. (when you turn option to show as hex)
you better check your PC code.

_________________
Mark
Back to top
View user's profile Visit poster's website
boeseturbo

Bascom Member



Joined: 23 Jul 2007
Posts: 31

blank.gif
PostPosted: Tue Mar 28, 2017 10:02 pm    Post subject: Reply with quote

Okay.... mscomm.ocx didnt show zero Sad(( have to check it... thank you very much
Back to top
View user's profile
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2113

netherlands.gif
PostPosted: Tue Mar 28, 2017 10:32 pm    Post subject: Reply with quote

To use mscomm.ocx in binary mode you have to setup it up something like this.
Code:

MSComm1.InputMode = comInputModeBinary
 

_________________
www.evertdekker.com Bascom code vault
Back to top
View user's profile Visit poster's website
boeseturbo

Bascom Member



Joined: 23 Jul 2007
Posts: 31

blank.gif
PostPosted: Wed Mar 29, 2017 7:28 am    Post subject: Reply with quote

Hi,

i used inputmode binary and also nulldiscard to false. when I use print chr(0) vb6 app didnt receive anything. Maybe it could be problem with bluetooth modul? I use HC-05 modul for data-transfer.
Also hyperterminal didnt receive zero byte.... MCS bootloader is full functional. Runs without any problems.


Cheers

here is my complete testcode:

Code:

$regfile = "xm128d4def.dat"
$crystal = 32000000
$hwstack = 400
$swstack = 400
$framesize = 400

Config Osc = Enabled , 32mhzosc = Enabled  , 32khzosc = Enabled
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1

CONFIG EEPROM=mapped

dim temp_byte as Byte
Dim Bblock As Byte
dim uart as Byte
dim csum as Byte

Config Priority = Static , Vector = Application , Lo = Enabled , Med = Enabled , Hi = Enabled
Config COM3 = 38400 , Mode = asynchroneous , Parity = None , Stopbits = 1 , Databits = 8       ' use USART C0
Config Serialout2 = Buffered , Size = 255
Enable Interrupts
Open "COM3:" For Binary As #1

do
  uart=inkey(#1)

  if uart =200 then
     csum=0
     for temp_byte = 1 to 128
     Readeeprom bblock , temp_byte
     print #1, chr(0);
     csum=csum+bblock
     next temp_byte
     printbin #1,csum;
  end if


   If uart = 123 Then
      Goto &H10000
   End If

Loop
End
 
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5061
Location: Holland

blank.gif
PostPosted: Wed Mar 29, 2017 9:19 am    Post subject: Reply with quote

both print and printbin send ascii values from 0-255.
i think you can simply solve it by sending data as hex using : print hex(myByte)
then all you need to do is to 'decode' the hex ascii data back with a loop like
for b=1 to len(someString) step 2
s=mid(s,b,2)
bytevalue=val("&H" + s)
next

_________________
Mark
Back to top
View user's profile Visit poster's website
boeseturbo

Bascom Member



Joined: 23 Jul 2007
Posts: 31

blank.gif
PostPosted: Wed Mar 29, 2017 12:35 pm    Post subject: Reply with quote

Hi Mark,

i solved it. In VB6 input of mscomm must gone into an array. Than it will work Smile

Cheers
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
Page 1 of 1

 
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