Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Nextion and Bascom
Goto page Previous  1, 2
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM Project Blog
View previous topic :: View next topic  
Author Message
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1191
Location: SYDNEY

australia.gif
PostPosted: Wed Apr 01, 2020 10:14 am    Post subject: Reply with quote

Thank you Mark
I thought it would be simple but I am very low in ASM
Could it be made into a bascom function.
Nexwave Very Happy

I think bascom and nextion make good partners
as bascom has a soft com port it can be used with the Arduino's with one com port

Nextion now has a CRC function I need to learn how to use it

Regards Paul & keep safe
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1191
Location: SYDNEY

australia.gif
PostPosted: Sat May 02, 2020 1:06 pm    Post subject: Reply with quote

Need to use array greater than 255 so how to with marks code
Worked it out I needed the extended printbin Very Happy
Regards Paul
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5003
Location: Holland

blank.gif
PostPosted: Mon May 04, 2020 10:21 am    Post subject: Reply with quote

this is the size :

! ldi r24,10 ; size of array
! ldi r25,0

i will post a function later.

_________________
Mark
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5003
Location: Holland

blank.gif
PostPosted: Mon May 04, 2020 11:37 am    Post subject: Reply with quote

Code:
'size of array in r24 and r25
Sub Copydown(ar() As Byte , Byreg R24 As Word)
   $asm
      Loadadr Ar(1) , Z                                     ; load address into r30 r31
      add r30,r24                                           ; add size
      adc r31,r25
      sbiw r30,1                                            ; adjust
_copydown:
      ld r23, -z                                            ; load byte
      std z+1,r23                                           ; save
      sbiw r24,1                                            ; adjust size counter
      brne _copydown                                        ; till it is zero
   $end Asm
End Sub


call it like :

Code:
Dim Ar(255) As Byte , J As Byte

Ar(1) = 1
Ar(2) = 2
Ar(3) = 3
Ar(4) = 4
Ar(5) = 5

Copydown Ar(1) , 255
For J = 1 To 10
  Print J ; "-" ; Ar(j)
Next

_________________
Mark
Back to top
View user's profile Visit poster's website
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1191
Location: SYDNEY

australia.gif
PostPosted: Mon May 04, 2020 11:42 am    Post subject: Reply with quote

Thankyou Mark
I worked out the size of array part but because the light bulb was slow to come on
in my head about printbin needing the =extended to print more than 255 elements
I thought I had it wrong.


Regards Paul
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1191
Location: SYDNEY

australia.gif
PostPosted: Mon May 04, 2020 11:52 am    Post subject: Reply with quote

Note for wave tool.

When using the Nextion wave for stored data a lot of ram is needed or an SD card
so the M1284p with 16k of ram is my choice.
The 7 inch screen will need up to 800 bytes to store 1 trace
so if 4 were used 3200 bytes.
The data is lost when you change to another screen so it has to be stored.

Regards Paul
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1191
Location: SYDNEY

australia.gif
PostPosted: Thu May 07, 2020 1:08 pm    Post subject: Reply with quote

Ok I am learning some asm it may not be well written
but as it works, it means I am learning to use it
all suggestions to improve are welcome as then I learn more.

Regards Paul

Code:



Sub W_one(byval M As Byte , Byval J As Byte)
Arx = J

   !push r23
   !push r24
   !push r25
   !push r26
   !push r27
   !push r30
   !push r22

Loadadr Wave1(1) , X
!lds r22,{arx}
!cpi r22,1
!breq gogo
Loadadr Wave2(1) , X
!lds r22,{arx}
!cpi r22,2
!breq gogo
Loadadr Wave3(1) , X
!lds r22,{arx}
!cpi r22,3
!breq gogo
Loadadr Wave4(1) , X
!lds r22,{arx}
!cpi r22,4
!brne gone
Gogo:



'Loadadr Wave1(1) , X                                        'first location
! ldi r24,188 ; size of array
! ldi r25,2
!add r26,r24                ; add size
!adc r27,r25
!movw r30,r26               ; copy to Z
!sbiw r30,1 ; adjust
!lp1000:
!ld r23,-z  ; load byte
!st -x,r23
!sbiw r24,1
!brne lp1000

 Gone:

   !pop r22
   !pop r30
   !pop r27
   !pop r26
   !pop r25
   !pop r24
   !pop r23

   Select Case Arx

     Case 1
       Wave1(1) = M

     Case 2
       Wave2(1) = M

     Case 3
       Wave3(1) = M

     Case 4
       Wave4(1) = M






   End Select

'Wave1(1) = M


End Sub

 
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM Project Blog All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
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