|
|
View previous topic :: View next topic |
Author |
Message |
oyhan
Joined: 03 Jun 2005 Posts: 21 Location: TURKEY
|
using 12f675 or 12F683 on RS232 |
Posted: Wed Aug 30, 2006 3:24 pm |
|
|
I do not use this code because it is sending difrence characters.. Why???
terminal speed and pic speed is same..
Code: |
#include <12F675.h>
#fuses INTRC_IO, NOWDT, NOMCLR, NOPROTECT, NOBROWNOUT
#use delay(clock=4000000)
#use rs232 (baud=2400, xmit=PIN_A5, rcv=PIN_A3, parity=N, bits=8)
void main()
{
port_a_pullups(TRUE);
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_comparator(NC_NC);
setup_vref(FALSE);
while(true)
{
printf("Press any key to begin\n\r");
printf("ABC abc 123\n\r");
delay_ms(1000);
}
}
|
Last edited by oyhan on Wed Aug 30, 2006 4:33 pm; edited 1 time in total |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Aug 30, 2006 4:13 pm |
|
|
I don't have a prototype board for the 12F675 that has a MAX232 chip
on it, so I added the INVERT option to the #use rs232() statement in
your program. I compiled it with PCM vs. 3.249. It works. Here is
the output:
Quote: |
Press any key to begin
ABC abc 123
Press any key to begin
ABC abc 123
Press any key to begin
ABC abc 123
Press any key to begin
ABC abc 123
|
So your problem could be:
1. If you don't have a MAX232-type chip, you need to add the INVERT
parameter.
2. It's possible that you erased the OSCCAL value at address 0x3FF
and then put in a new one, but the value is incorrect, so the internal
oscillator runs at some incorrect frequency (Not at 4.0 MHz anymore). |
|
|
oyhan
Joined: 03 Jun 2005 Posts: 21 Location: TURKEY
|
|
Posted: Wed Aug 30, 2006 4:32 pm |
|
|
It's okey. thanks pcm_programmer:::
Code: |
#include <12F683.h>
#fuses NOWDT, INTRC_IO, NOCPD, NOPROTECT, NOMCLR, NOPUT
#use delay (clock=8000000)
#fuses INTRC, NOWDT, NOMCLR
#use rs232 (baud=9600, xmit=PIN_A5, rcv=PIN_A3, parity=N, bits=8, INVERT)
void main()
{
setup_oscillator(OSC_8MHZ);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_comparator(NC_NC);
setup_vref(FALSE);
set_tris_a(0b00001000);
while (1)
{
printf("Press any key to begin\n\r");
printf("ABC abc 123\n\r");
delay_ms(1000);
}
}
|
|
|
|
oyhan
Joined: 03 Jun 2005 Posts: 21 Location: TURKEY
|
|
Posted: Wed Aug 30, 2006 5:35 pm |
|
|
Quote: | 2. It's possible that you erased the OSCCAL value at address 0x3FF
and then put in a new one, but the value is incorrect, so the internal
oscillator runs at some incorrect frequency (Not at 4.0 MHz anymore) |
Do you know how? I want to calibrate 12f675 but I do not know how do I? |
|
|
Ttelmah Guest
|
|
Posted: Thu Aug 31, 2006 2:48 pm |
|
|
Do you have access to a frequency meter?.
If so, then the 'key' is that the value written to the OSCCAL register, adjusts the clock. What I'd do, is make a program, that scans three buttons. When the first is pushed, it increments the OSCCAL value. When the second is pushed it decrements the OSCCAL value. When the third is pushed, it sends the current OSCCAL value out the serial. The register is at address 0x90, and the value uses the top six bits of the register (so increment/decrement in fours). Have the chip set to output the OSC/4 frequency on GP4. Start the chip up with a value of 128, and then push the buttons to adjust the value. Once the fequency is 'right', send this value over the serial (which will then work), and you can store this as as the required calibration value (as a RETLW instruction with this value).
Some programmers have an automated ability to do this (they take advantage of the ability to run code without programming it into the chip, perform this operation, and compare the frequencies with their own crystal, till they get an acceptable match). The manual system for a given supply voltage, and temperature, gives the 'best' results (depending on how good your frequency meter is).
Best Wishes |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|