|
A member of the mp3car.com forums asked me to help by modifying the firmware of the PIC on his M2-ATX carPC power supply. The M2-ATX is a popular supply amongst the carPC community; I do not personally own one, but the code was straightforward enough that the modifications aren't very complex, so it's mainly a fun mini-project for me. First off, the firmware is available at: http://www.epiacenter.com/downloads/itatx2.zip It's pretty basic, just a typical MPLAB project folder in the zip, with a single .ASM file containing all the code. The code itself is quite well-commented and easy to follow, thankfully.
First step with any unfamiliar program is sorting out how it progresses during normal operation, what the 'main code' is, etc. On power up, the M2 jumps to the label 'reset', initializes a bunch of registers, reads the jumper settings, and then waits for ignition (unless it's in dumb supply mode). Skip ahead a bit, to when the thing is running, with the ignition on. There it sits in a loop, running the lines from 'onstate' to three lines into 'onstate1'. There it repeatedly runs check_alternate_swith(sic), checks the jumpers, ignition, and executes the routine 'on200'; 'on200' is a main routine that runs for ~200mS per call. In it, signals such as the amp turn-on, and the ATX signals PGOOD and PSON are handled. As for the time delays associated with each of the possible modes set by the jumpers, they are all set by a set of 4 tables, which retrieve the high and low bytes (making a 16-bit value) for the 16-bit counter which is used to countdown for the delay. offtabl movfw switch addwf PCL,f retlw .0 ;switch 0: never retlw .26 ;switch 1: 5 s retlw .26 ;switch 2: 5 s retlw .26 ;switch 3: 5 s retlw .151 ;switch 4: 30 s retlw .151 ;switch 5: 30 s retlw .0 ;switch 6: 30 min retlw .0 ;switch 7: 3 hrs retlw .0 ;switch 8: 10 min retlw .0 ;switch 9: 15 min retlw .0 ;switch 10: 1 hour retlw .26 ;switch 11: 5 s | offtabh movfw switch addwf PCL,f retlw .0 ;switch 0: never retlw .1 ;switch 1: 5 s retlw .1 ;switch 2: 5 s retlw .1 ;switch 3: 5 s retlw .1 ;switch 4: 30 s retlw .1 ;switch 5: 30 s retlw .36 ;switch 6: 30 min retlw .212 ;switch 7: 3 hrs retlw .11 ;switch 8: 10 min retlw .18 ;switch 9: 15 min retlw .70 ;switch 10: 1 hour retlw .1 ;switch 11: 5 s
| hardtabl movfw switch addwf PCL,f retlw .0 ;switch 0: never retlw .50 ;switch 1: 1 min retlw .0 ;switch 2: 2 hrs retlw .0 ;switch 3: never retlw .0 ;switch 4: 2 hrs retlw .0 ;switch 5: never retlw .0 ;switch 6: never retlw .0 ;switch 7: never retlw .0 ;switch 8: 1 hrs retlw .0 ;switch 9: 2 hrs retlw .0 ;switch 10: 1h 15min retlw .0 ;switch 11: 2 hrs | hardtabh movfw switch addwf PCL,f retlw .0 ;switch 0: never retlw .2 ;switch 1: 1 min retlw .142 ;switch 2: 2 hrs retlw .0 ;switch 3: never retlw .142 ;switch 4: 2 hrs retlw .0 ;switch 5: never retlw .0 ;switch 6: never retlw .0 ;switch 7: never retlw .70 ;switch 8: 1 hrs retlw .142 ;switch 9: 2 hrs retlw .88 ;switch 10: 1h 15min retlw .142 ;switch 11: 2 hrs |
So, the only thing one needs to do to change the time delay for a given mode is to change the appropriate pairs of 8-bit values. From these values, the rate of countdown can be determined to be about 5 counts per second, and a value of 0x0000 is considered "never". Note that the values are 1 greater than the actual count they represent - the 5 second delay is a count of 25, so it should be 0 in the high register, 25 in the lower, but it is seen to be 1 and 26. This is because the values are first decremented before they are checked to be zero. Simply put, for those of you who are only looking to simply change timings without messing with other stuff:
The value in the high register should be ((time in seconds)*5/256)+1 (rounded to nearest integer) The value in the low register should be ((time in seconds)*5)-((value in high register)*256)+1 (offtabl and hardtabl represent the low register, offtabh and hardtabh represent the high register)
|