View previous topic :: View next topic |
Author |
Message |
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Thu May 24, 2018 11:41 am Post subject: |
|
|
As using a full byte consumes a lot of ram
I decided to try to write some asm to send one byte to a 74hc595
but its almost working just need some help to get there
UPDATE
OK got it working now how to send a byte variable from bascom to it
Regards Paul
Code: |
$asm
PUSH R16
push R17
push R18
PUSH R19
' Send 8-bit data to 74HC595 Shift Register
ldi R16,0b1010_0100 ;test data now how to put data in from byte variable in bascom
Send_byte:
ldi R19,0b1000_0000 ; Set Bit counter
Next_bit:
mov R17,R16 ; Move data byte to temp
and R17,R19 ; Check bit
breq zero ; Set Data to 0
sbi Panel_r1_p, Panel_r1_b ; Set Data to 1
rjmp shift ; shift bits
Zero:
cbi Panel_r1_p, Panel_r1_b
Shift:
sbi Panel_clk_p, Panel_clk_b ; CLK up
nop
cbi Panel_clk_p, Panel_clk_b ; CLK down
clc ; Clear Carry flag
ror R19 ; Shift bit counter
brne next_bit ; Next iteration
sbi Panel_lat_p, Panel_lat_b ; When done, Latch
nop
cbi Panel_lat_p, Panel_lat_b
POP R16
POP R17
POP R18
POP R19
$end Asm
|
|
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Thu May 24, 2018 1:15 pm Post subject: |
|
|
Now it is working next to get it into O-Family's code
Regards Paul
Code: |
$asm
PUSH R16
push R17
push R18
PUSH R19
push XL
PUSH XH
' Send 8-bit data to 74HC595 Shift Register
Loadadr Transfer_bits , X
ld R16,X+
Send_byte:
ldi R19,0b1000_0000 ; Set Bit counter
Next_bit:
mov R17,R16 ; Move data byte to temp
and R17,R19 ; Check bit
breq zero ; Set Data to 0
sbi Panel_r1_p, Panel_r1_b ; Set Data to 1
rjmp shift ; shift bits
Zero:
cbi Panel_r1_p, Panel_r1_b
Shift:
sbi Panel_clk_p, Panel_clk_b ; CLK up
nop
cbi Panel_clk_p, Panel_clk_b ; CLK down
clc ; Clear Carry flag
ror R19 ; Shift bit counter
brne next_bit ; Next iteration
sbi Panel_lat_p, Panel_lat_b ; When done, Latch
nop
cbi Panel_lat_p, Panel_lat_b
POP R16
POP R17
POP R18
POP R19
POP XL
POP XH
$end Asm
|
|
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
Posted: Fri May 25, 2018 1:11 am Post subject: |
|
|
I don even try to realize/resolve this.. but Im thinking that POP`ing should be some kind of reversed way
My thinking was that RETI takes last saved PK |
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Sat May 26, 2018 1:08 am Post subject: |
|
|
Hi,
To calculate the position (address) of the LED buffer, a multiplication (MUL) instruction is required.
Therefore, a program for reusing the registers R0, R1 is suitable.
And I think that the 74HC595 is 8 serial connections, so we need to send 8 bytes with one interrupt. |
|
Back to top |
|
|
sangwoo
Joined: 19 Nov 2016 Posts: 3
|
Posted: Mon Jul 09, 2018 3:36 pm Post subject: Hello O-Family |
|
|
Hello O-Family
Thank you for answer.
on drawing subroutine
Add LEDY 3, LEDY 4
Do I have to add up two lines each?
It\'s a lot more complicated than I thought. |
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Sat Jul 14, 2018 4:14 am Post subject: |
|
|
Yes.
My routine supports RGB color, so the correction will be more.
In the first place, with single color and RGB full color you need to change the structure of the display memory greatly.
I will support your efforts. |
|
Back to top |
|
|
sangwoo
Joined: 19 Nov 2016 Posts: 3
|
Posted: Mon Jul 16, 2018 4:26 pm Post subject: |
|
|
Thank O-Family
I did it
One line below has been added.
If Ledy = 2 Or Ledy = 4 Then Ledtempw1 = Ledtempw1 + 256 |
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Fri Jul 20, 2018 2:05 pm Post subject: |
|
|
Hi, sangwoo
It was nice to finish!
The fact that the number of dots is large is because many information can be displayed, so I think that an interesting device will be completed! |
|
Back to top |
|
|
mansur
Joined: 21 Feb 2013 Posts: 37 Location: Jakarta
|
Posted: Tue Aug 21, 2018 2:37 am Post subject: |
|
|
Hi O-Family,
thanks for sharing,
but i dont understand and difficult to asm understanding.
can you provide the full bascom language even need more RAM.
Thanks. _________________ Mansur. H
Automation & Instrument Engineer |
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Thu Aug 23, 2018 11:55 am Post subject: |
|
|
Hi, mansur
I do not understand the meaning of the question.
What help do you need? |
|
Back to top |
|
|
mansur
Joined: 21 Feb 2013 Posts: 37 Location: Jakarta
|
Posted: Tue Aug 28, 2018 4:37 am Post subject: |
|
|
[quote=\"O-Family\"]Hi, mansur
I do not understand the meaning of the question.
What help do you need?[/quote]
I mean, can you provide the full bascom source?
because i\'m not understand about your program in assembler:
Code: | $notransform On \'Do not automatically correct instructions that use R23 or R0.
\'
$asm
Tint2a:
PUSH R2
IN R2,SREG \'Saved status register.
PUSH R0
PUSH R1
PUSH XL
PUSH XH
;
LDS XL,{rowadr} \'Read the row address of the LED buffer.
LDI XH, Ledbuff_Length \'Number of horizontal axis bytes of LED buffer. (32 horizontal dots * number of panels + scroll buffer)
MUL XH,XL \'Calculate the position of the LED buffer.
Loadadr Ledbuff(1) , X \'RGB LED panel The start address of the data buffer.
ADD XL,R0 \'Add the row address to the LED buffer.
ADC XH,R1
;
LDS R0,{Transfer_Length} \'The number of bytes to transfer to the LED buffer.
Tint2a1:
LD R1,X+ \'Read lit data from the LED buffer.
Out Panel_rgb , R1 \'Set RGB data.
SBI Panel_clk_p, Panel_clk_b \'Set the RGB LED panel [CLK] to [H].
CBI Panel_clk_p, Panel_clk_b \'Set the RGB LED panel [CLK] to [L].
DEC R0
BRNE Tint2a1 \'If Transfer end for the number of horizontal axis bytes? Else
;
LDS XL,{rowadr} \'Read row address.
SBI Panel_oe_p, Panel_oe_b \'Set the RGB LED panel [OE] to [H]. (Turn off all LEDs)
SBI Panel_lat_p, Panel_lat_b \'Set the RGB LED panel [LAT] to [H].
CBI Panel_lat_p, Panel_lat_b \'Set the RGB LED panel [LAT] to [L].
;
CBI Panel_a_p, Panel_a_b \'Set the row address to the port.
CBI Panel_b_p, Panel_b_b
CBI Panel_c_p, Panel_c_b
SBRC XL,0
SBI Panel_a_p, Panel_a_b
SBRC XL,1
SBI Panel_b_p, Panel_b_b
SBRC XL,2
SBI Panel_c_p, Panel_c_b
INC XL \'Increase row address.
ANDI XL,$07
STS {rowadr},XL \'Save the row address.
;
POP XH
POP XL
POP R1
POP R0
Out Sreg , R2 \'Return status register.
POP R2
CBI Panel_oe_p, Panel_oe_b \'Set the RGB LED panel [OE] to [L].
RETI
$end Asm
\'
\' ************************************
\' * Timer2 Compare Match B interrupt *
\' ************************************
\'
$asm
Tint2b:
PUSH R24
SBI Panel_oe_p, Panel_oe_b \'Set the RGB LED panel [OE] to [H].
LDI R24,$FF
STS {Ledintf},R24 \'Set the LED display interrupt generation flag.
POP R24
RETI
$end Asm
\'
$notransform Off |
Thanks for your attention. _________________ Mansur. H
Automation & Instrument Engineer |
|
Back to top |
|
|
|
|
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
|
|