Does Timer1 Prescale affect the Serin baud rate?
Does the prescale affect the serin baud rate?
I am using one chip to talk to another.
I just got in my SX48 Protoboard and put this code on it.
However I tried different baud rates for the sending serout and receiving serin with no luck.
I really wanted to send a word but I am still having problems getting a byte to tranfer.
here is an example of my sending code from another brand·chip.·This is on another board.
I have both boards powered by the same source so the ground and levels are the same.
and my sx48 code.
I am using one chip to talk to another.
I just got in my SX48 Protoboard and put this code on it.
However I tried different baud rates for the sending serout and receiving serin with no luck.
I really wanted to send a word but I am still having problems getting a byte to tranfer.
here is an example of my sending code from another brand·chip.·This is on another board.
I have both boards powered by the same source so the ground and levels are the same.
If Key_Value=12 then high 1 pause 200 SerOut 0, T4800, (B1) pause 250 low 1 endif
and my sx48 code.
DEVICE SX48, OSCXT1 FREQ 4_000_000
IrLed VAR RB.6 frequency var Byte 'frequency var word delay var word half_delay var word
PROGRAM Start
Start: OUTPUT IrLed Input RA.0 TIMER1 PRESCALE, 6 ' 6 = 1:64 prescaler Delay = 62500 / frequency ' enable LED output Half_Delay = 31250 / frequency
TIMER1 PWM, half_Delay, Delay
DO new: If RA.1 = 1 then pause 200 SERIN RA.0, T4800, Frequency, 200, new ' SERIN RA.0, T4800, Frequency_MSB, 200, new ' SERIN RA.0, T4800, Frequency_LSB, 200, new watch frequency Goto start endif LOOP END
Comments
You are probably missing the character. You should just loop to new: until the pin goes high.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Teacher: What is the difference between ignorance and apathy ?
Student: I don't know and I don't care
Teacher: Correct !
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
Post Edited (JonnyMac) : 8/14/2007 2:09:45 AM GMT
I got it to work ok except for the 1 hz where I would see it drop to 0.65 hz. I did not try Jon's correction yet.
But my bigger problem is getting the hard reset to work. It runs fine when I rerun it from the Key and use the reset button.
But when I remove the power from the 7.5V 800mA wall wart it will not restart.
I searched these forums and tried some suggested directives but they did not help either. Do I need to set the Fusex directly?
here is my code:
When you run code with the SX-Key, you program the chip using the Run->Debug (CTRL-D) menu option. To have the chip run without the SX-Key, you program using the Run->Program (CTRL-P) option. In addition, you need to have an external clock (TTL, resonator, or crystal) attached as you have specified OSCXT1 in your device directive.
Thanks,
PeterM
I have always used CTRL-R.
But wouldn't OSCXT1 work because I am currently using the KEY as the osc source.
Does powering down and up again disable the key osc?
I've updated my version of the program (see above) so that it uses the RTS.
· Can you post a small program that demonstrates the error. I will fix it in the next release.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Teacher: What is the difference between ignorance and apathy ?
Student: I don't know and I don't care
Teacher: Correct !
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
Post Edited (JonnyMac) : 8/14/2007 2:14:39 AM GMT
If you comment out the IF-THEN section of this subroutine so that just the ELSE statements are active you will see that sending 1 Hz results in an output of 2.
Yes, if you power down the key will stop clocking; you can reset by pullig MCLR low, but don't power down the key. Better yet, pop a 4 MHz resonator into your board and use Ctrl+P to program.
Thanks, I found the problem. I will get it fixed.
The problem occurs when you divide a word value that is > 32767 by 1.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Teacher: What is the difference between ignorance and apathy ?
Student: I don't know and I don't care
Teacher: Correct !
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
Yes, it does. When you power down and up again the key, it performs a reset, and stays in a loop, waiting for a connect string from the SX-Key IDE. As long as you maintain power after Ctrl-R, or Ctrl-K, the SX-Key generates the clock signal, even when you remove the serial cable, or shut down the SX-Key IDE.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
Steve
Post Edited (JonnyMac) : 8/14/2007 4:26:50 PM GMT
My current range of movement would need a 24 bit variable. However if I count every x steps I can probably get it to a 16bit value.
Is there some internal counter?
TIMER2 EXTERNAL
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Teacher: What is the difference between ignorance and apathy ?
Student: I don't know and I don't care
Teacher: Correct !
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
Post Edited (Bean (Hitt Consulting)) : 8/15/2007 1:37:05 PM GMT
Just make the output an input?
Then back to output when I want to turn it on again?