|
|
© MCS Electronics, 1995-2007 |
' |
|
|
'----------- |
configure the pins we use ------------ |
Config Bccard = D , Io = 5 , Reset = 4 |
' |
^ |
^ PORTD.4 |
' |
PORTD.5 |
' |
^--------------------- |
PORT D |
'Load the sample calc.bas into the basiccard
'Now define the procedure in BASCOM
'We pass a string and also receive a string
Bcdef Calc(string)
'We need to dim the following variables 'SW1 and SW2 are returned by the BasicCard
'BC_PCB must be set to 0 before you start a session
'Our program uses a string to pass the data so DIM it
Dim S As String * 15
'Baudrate might be changed $baud = 9600
' Crystal used must be 3579545 since it is connected to the Card too $crystal = 3579545
'Perform an ATR
Bcreset
'Now we call the procedure in the BasicCard
'bccall funcname(nad,cla,ins,p1,p2,PRM as TYPE,PRM as TYPE)
S = "1+1+3" ' we want to calculate the result of this expression
Bccall Calc(0 , &H20 , 1 , 0 , 0 , S) |
variable to pass that holds the |
' |
^--- |
expression |
^ |
P2 |
' |
' |
^----------- |
P1 |
' |
^--------------- |
INS |
' |
^-------------------- |
CLA |
'^-------------------------- NAD
'For info about NAD, CLA, INS, P1 and P2 see your BasicCard manual 'if an error occurs ERR is set
' The BCCALL returns also the variables SW1 and SW2 Print "Result of calc : " ; S
Print "SW1 = " ; Hex(sw1)
Print "SW2 = " ; Hex(sw2)
'Print Hex(_bc_pcb) ' for test you can see that it toggles between 0 and 40 Print "Error : " ; Err
'You can call this or another function again in this session
S = "2+2"
Bccall Calc(0 , &H20 , 1 , 0 , 0 , S) Print "Result of calc : " ; S
Print "SW1 = " ; Hex(sw1)
Print "SW2 = " ; Hex(sw2)
'Print Hex(_bc_pcb) ' for test you can see that it toggles between 0 and 40 Print "Error : " ; Err