Hest
Junior Member level 1
- Joined
- Jun 14, 2011
- Messages
- 19
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,436
Hello
I'm working with microprocessors and using hi-tech C for my programs.
I have an assembly program that I would like to re-make into C. The assembly code is for a PIC12f629 for modelcars with lights and blinking LED's.
I could just use it as it is, but I'd like to learn more my self and make some changes to it.
Because the code is so large, I have attached the ASM file as well as posted the code below:
DO NOT PUT 1500 LINES OF ASM CODE INLINE - ONLY INCLUDE THEM IN ATTACHMENTS
Here is a little code snip that explains my question.
Just an example. In the code he has got this:
I can understand the most of the assembly code, but I can't figure out where this program is getting it's timing from and where those 245 and 45 comes in ans where he turns on and off those LED. I know what they mean, but not what counts it. It's really bugging me and I have played around with it for a while now.
I have been trying to figure out exactly how the program counts the time/ticks and decides what pin to turn on or off and when it resets and starts over. It's not timer0 because thats too fast. I think timer1 is used for every run through the program, but then I don't get why he only counts to 245 and 45 in his timings, because I tested that and that is way to fast.
I hope someone can guide me in the right direction and maybe explain to me a little more precise what happends and where those timings are used. Or maybe if someone could make just a small C example that uses some of his timings, so I can work from there.
I'm working with microprocessors and using hi-tech C for my programs.
I have an assembly program that I would like to re-make into C. The assembly code is for a PIC12f629 for modelcars with lights and blinking LED's.
I could just use it as it is, but I'd like to learn more my self and make some changes to it.
Because the code is so large, I have attached the ASM file as well as posted the code below:
DO NOT PUT 1500 LINES OF ASM CODE INLINE - ONLY INCLUDE THEM IN ATTACHMENTS
Here is a little code snip that explains my question.
Just an example. In the code he has got this:
Code:
R_CNT_F1 equ 30h ; Counter for FLASH1
R_FLAG_F1 equ 31h ; FLAGS for FLASH1
Code:
T_FLASH1 equ d'245' ; (1..255) duration of long off-time for FLASH1
T_BREAK1 equ d'45' ; (1..255) duration of short off-time for FLASH1
Code:
movlw T_FLASH1 ; Time between 2 Flashes (long time)
btfss R_FLAG_F1,0 ; if short off-Time needed (Strobo double-flash)
movlw T_BREAK1 ; Time between 2 Flashes (short time)
subwf R_CNT_F1,W ; if R_CNT_F1 < T_FLASHx / T_BREAKx
btfss STATUS,C ; .. then
return ; return
I can understand the most of the assembly code, but I can't figure out where this program is getting it's timing from and where those 245 and 45 comes in ans where he turns on and off those LED. I know what they mean, but not what counts it. It's really bugging me and I have played around with it for a while now.
I have been trying to figure out exactly how the program counts the time/ticks and decides what pin to turn on or off and when it resets and starts over. It's not timer0 because thats too fast. I think timer1 is used for every run through the program, but then I don't get why he only counts to 245 and 45 in his timings, because I tested that and that is way to fast.
I hope someone can guide me in the right direction and maybe explain to me a little more precise what happends and where those timings are used. Or maybe if someone could make just a small C example that uses some of his timings, so I can work from there.
Attachments
Last edited by a moderator: