View previous topic :: View next topic |
Author |
Message |
boeseturbo
Joined: 23 Jul 2007 Posts: 46
|
Posted: Tue Mar 28, 2017 4:51 pm Post subject: want to transfer eeprom via UART to PC... Problem with binar |
|
|
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 |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Tue Mar 28, 2017 7:14 pm Post subject: |
|
|
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 |
|
|
boeseturbo
Joined: 23 Jul 2007 Posts: 46
|
Posted: Tue Mar 28, 2017 10:02 pm Post subject: |
|
|
Okay.... mscomm.ocx didnt show zero (( have to check it... thank you very much |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Tue Mar 28, 2017 10:32 pm Post subject: |
|
|
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 |
|
|
boeseturbo
Joined: 23 Jul 2007 Posts: 46
|
Posted: Wed Mar 29, 2017 7:28 am Post subject: |
|
|
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 |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Wed Mar 29, 2017 9:19 am Post subject: |
|
|
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 |
|
|
boeseturbo
Joined: 23 Jul 2007 Posts: 46
|
Posted: Wed Mar 29, 2017 12:35 pm Post subject: |
|
|
Hi Mark,
i solved it. In VB6 input of mscomm must gone into an array. Than it will work
Cheers |
|
Back to top |
|
|
|