Multiplication with PIC18F458
Posted: 15 May 2014 20:38
HELLO,
Here's my problem:
i'd like to do a multiplication with PIC18F448 only, so i've two variabls X1 configured on PORTB 8bits & X2 configured on PORTC 4bits,
i've got to read whats on X1 & X2 first then do M=X1*X2; as 0*1, 0*....til 15*255 so i need 4 digit seven segments display maximum, on PORTA.
All i knw is
VAR X1,X2 : byte; M: word;
Begin
trisB:=0;
trisc:=0;
trisa:=0;
For x1:= 0 to 255 do
begin
For x2:= 0 to 15 do
begin
M:=x1*x2;
porta:=M; setbit(), delay_ms(1000); clearbit()// dont know how to configur this too
end;
end;
end.
i dnt knw how to decode all that for the 4 digits,,shoud i use
Function decode(M:word):word;
begin
if M:=o then decode:=$c0;
if M:=1 then decode:=$f9;
if M:=3225 then decode:=$0C99;
end;
but its toooo loo...ooong
All i've is a pic18F458 & 4digits seven segments display,,
Thanks in advance.
Here's my problem:
i'd like to do a multiplication with PIC18F448 only, so i've two variabls X1 configured on PORTB 8bits & X2 configured on PORTC 4bits,
i've got to read whats on X1 & X2 first then do M=X1*X2; as 0*1, 0*....til 15*255 so i need 4 digit seven segments display maximum, on PORTA.
All i knw is
VAR X1,X2 : byte; M: word;
Begin
trisB:=0;
trisc:=0;
trisa:=0;
For x1:= 0 to 255 do
begin
For x2:= 0 to 15 do
begin
M:=x1*x2;
porta:=M; setbit(), delay_ms(1000); clearbit()// dont know how to configur this too
end;
end;
end.
i dnt knw how to decode all that for the 4 digits,,shoud i use
Function decode(M:word):word;
begin
if M:=o then decode:=$c0;
if M:=1 then decode:=$f9;
if M:=3225 then decode:=$0C99;
end;
but its toooo loo...ooong
All i've is a pic18F458 & 4digits seven segments display,,
Thanks in advance.