Author Topic: I can't find a function, c166 assembler. (solved)  (Read 917 times)

0 Members and 1 Guest are viewing this topic.

Offline Postal2Topic starter

  • Frequent Contributor
  • **
  • !
  • Posts: 826
  • Country: 00
I can't find a function, c166 assembler. (solved)
« on: November 30, 2024, 03:04:12 pm »
CPU C164CI. It is known that the motor encoder is connected to P3.4 and P3.6. I can't find a function in the firmware that reads these pins. Does anyone understand C166 assembler?
« Last Edit: November 30, 2024, 07:05:52 pm by Postal2 »
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6420
  • Country: es
Re: I can't find a function, c166 assembler.
« Reply #1 on: November 30, 2024, 03:53:41 pm »
Did you try c166-ghidra-module? Working in latest Ghidra v11.2.1.

Check the c164 User Manual and Datasheet, it's probably used in alternate function mode, connected to a timer in Incremental Interface Mode.


2449837-0


Edit: I found FUN_01dc52 doing T3CON = 0x1b3  (0 1 1 0 110 011)
This effectively sets T3 into incremental interface mode. In this mode, the timer runs automatically from the encoder pulses.
If you want to know what uses the encoder, find what reads T3, but I wasn't able to find it out, neither anything setting T3 interrupts (T3IC reg) or anything else accessing T3, it might be using some sort of byte SFR addressing or indirect addressing that Ghidra isn't recognizing.

Attached the decompiled program.

2449853-1

2449865-2
« Last Edit: November 30, 2024, 05:27:03 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline Postal2Topic starter

  • Frequent Contributor
  • **
  • !
  • Posts: 826
  • Country: 00
Re: I can't find a function, c166 assembler.
« Reply #2 on: November 30, 2024, 05:01:31 pm »
.... This effectively sets T3 into incremental interface mode. In this mode, the timer runs automatically from the encoder pulses.
Oh, thank you! That thought never occurred to me! I was straining my eyes trying to find the port address. I'll check now!

Did you try c166-ghidra-module? Working in latest Ghidra v11.2.1.
No, I haven't tried it, but I liked your decompilation. I'll set up this tool too. I'm using Ida (screenshot).
I was looking for a port reference, because I suspected that the encoder was outputting some serial number at startup.
« Last Edit: November 30, 2024, 06:07:31 pm by Postal2 »
 

Offline Postal2Topic starter

  • Frequent Contributor
  • **
  • !
  • Posts: 826
  • Country: 00
Re: I can't find a function, c166 assembler.
« Reply #3 on: November 30, 2024, 06:43:44 pm »
Great! Now everything is clear, thank you. This piece of iron managed to deceive me after all.
« Last Edit: November 30, 2024, 06:45:33 pm by Postal2 »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf