im really thankful for you reply.
I know about cheap and good modules out there, but dont anyone try to make some from scratch, it easy to fing FM bugs circuits in google but searching for rf module give really few results
im really thankful for you reply.
I know about cheap and good modules out there, but dont anyone try to make some from scratch, it easy to fing FM bugs circuits in google but searching for rf module give really few results
Not to muddy the waters because it sounds like you have decided on another route, but for completeness ...
at 4 MHz, 3 instructions on and 3 instruction off = 6 instructions per cycle, therefore f=1000000/6=166666.667 Hz (twice that noted above)Code:Start: PortB.1 = 1 'Set pin high @ NOP 'Wait....Two NOP's are neede if we want 50% dutycycle @ NOP 'since the GOTO takes two instruction cylcles. PortB.1 = 0 'Set pin low Goto Start 'Do it again. The GOTO takes the same time as two NOP's
Interestingly enough the above code does 3 instructions on and 4 instructions off on 16F devices and 3 on 3 off on 18F (at least on an 18F877A and 18F452, respectively). To combat this on the 16F's, you could do something like this in ASM
Good LuckCode:ASM here bsf PORTB,1 NOP NOP bcf PORTB, 1 goto here ENDASM
Last edited by paul borgmeier; - 5th March 2007 at 22:02.
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Hi Paul,
Thanks for filling in and for correcting me. My head seems to be completely messed up today - can't seem to get one thing right.....
How come it differs between 16F and 18F parts? I haven't looked at the generated code but would've thought that the compiler generated just what you wrote in the 'pure asm' example.
Anyway, I'm off to bed now. Not doing much good anyway.
Thanks
/Henrik Olsson.
The 16F code inserts a "clrf PCLATH" command before the goto - the 18F uses the bra command (instead of goto) and does not - why PBP inserts the clrf PCLATH, I would guess because "Start:" is in page 0 where PCLATH = 0 (EDIT: and does not check to see if we are already in page 0, which we are)
Last edited by paul borgmeier; - 5th March 2007 at 23:06.
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Hi Paul,
New day, fresh head...
You said:
That is of course correct. I based my calculation on a 20Mhz so 5000000/6 = 833kHz which is what I stated in my post which is also correct (but not half of 166kHz).at 4 MHz, 3 instructions on and 3 instruction off = 6 instructions per cycle, therefore f=1000000/6=166666.667 Hz (twice that noted above)
Thanks for the 16F vs 18F explanation. I guess it would take up more code to check which bank we're in before each goto instead of just setting the correct one?
Thanks!
/Henrik Olsson.
Henrik,
My apologies - you are and were indeed correct (166.667 / 2 != 833.33).
I am guessing the 16F PBP compiler code is not optimized to check to see if it is in the same page as the goto. I bet it sets the PCLATH every time it encounters a goto just to be safe. I do not think it would add PIC code - I think it would take more compiler code to do this check - MELABS must not have thought it was not worth it to potentially save one instruction (100% guess by me)?
Paul Borgmeier
Salt Lake City, UT
USA
__________________
I think it will use the CHK?RP macro simply for safety sake. sure the code is not optimized in any sort, but it's always solid as rock. When you need something tight, use ASM. Hence, for safety sake and for none 18Xxxxx your asm example could be...
PORTB.1=0 call MOVE?CT macro. wich isCode:ASM CHK?RP ; make sure we are on the right BANK here bsf PORTB,1 NOP NOP bcf PORTB, 1 goto here ENDASM
there you discover the extra cycleCode:MOVE?CT macro Cin, Regout, Bitout CHK?RP Regout if (((Cin) & 1) == 1) bsf Regout, Bitout else bcf Regout, Bitout endif endm
Last edited by mister_e; - 6th March 2007 at 16:53.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks