Yep iirc can-bus uses 2 bytes to store word nmot_w
and stock function looks like that
mov r4, nmot
movb 0xF825, rl4
movb 0xF824, rh4
Change wih
calls #8Ch, #1000h
movb 0xF825, rl4
movb 0xF824, rh4
Your routine @0xC1000
<...some calculations>
ends with
loc_1:
mov r4, #1234h ; use value equal to 1000rpm, 1234 just for example
rets
loc_2:
mov r4, #5678h ;equal 2000rpm
rets
loc_def:
mov r4, nmot_w ; actual nmot to canbus
rets
----
as for cmp its just a subtraction operation iirc, so if you need to know values are equal to each other just use cc_z
as for timer - its a counter (ram variable) which you init, add value to it and reset if its reaching its maximum value
initialize timer in main multimap routine (timer=0) due to unused ram are typically FF
i believe youve made a simple trigger to switch maps only once when button was pressed to prevent a switching loop
use this trigger in your can-bus routine to start the timer
so basically your routine shold looks like that
1. check for map swiching event. if its present, start the timer. just add 1 to the timer
2. check if timer is running. if timer value > 0 and value < threshold, add 1 to timer and mov selected map to the cluster. if timer >= threshold, mov nmot to the cluster (stock path) and reset the timer (mov timer, zeros).
result would be smooth af
https://youtu.be/3__up1h4xn4And btw
Beware of using canbus nmot hook on the go when the car equipped with AT/ESP/Haldex
Safety cap of rl_w or vss should be used aswell to prevent inadequate reaction of those modules