Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Why this Function don't work?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
pinkfloyd11

Bascom Member



Joined: 02 Jul 2007
Posts: 248

italy.gif
PostPosted: Mon Dec 03, 2007 3:39 pm    Post subject: Why this Function don't work? Reply with quote

Dear Friends

I have written code for read NRam memory and it work. After I have wrapper it in a function but with my surprise it don't work.
Can you help me to discovery why? Thanks.

working code
call Set_Address(3)
waitms 1
CE = Attivato
waitms 1
OE = Attivato
waitms 1
print Get_Byte()
waitms 1
OE = Disattivato
CE = Disattivato



NOT WORKING CODE
Declare Function Read_Byte(Byval Indirizzo as Integer) as byte
....
print read_byte(3)
....
Function Read_Byte(ByVal Indirizzo as Integer) as byte

call Set_Address(Indirizzo)
waitms 1
CE = Attivato
waitms 1
OE = Attivato
waitms 1
Read_Byte = Get_Byte()
waitms 1
OE = Disattivato
CE = Disattivato

end Function
........
Function Get_Byte() As Byte

Config PORTC = INPUT
PortC = 255
Get_Byte = Pinc

End Function
Back to top
View user's profile
ex4

Bascom Member



Joined: 13 Jan 2006
Posts: 1064
Location: indonesia

indonesia.gif
PostPosted: Tue Dec 04, 2007 9:11 am    Post subject: Reply with quote

change this
Read_Byte = Get_Byte()

to

local loc_res as byte
loc_res = Get_Byte()
Read_Byte = loc_res
Back to top
View user's profile Visit poster's website AIM Address Yahoo Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive 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