|
|
View previous topic :: View next topic |
Author |
Message |
grasspuddle
Joined: 15 Jun 2006 Posts: 66
|
Garbage sent with software uart |
Posted: Tue Mar 20, 2007 8:16 am |
|
|
pic18f452
code:
Code: |
main.h:
#include <18F452.h>
#device adc=8
#device *=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS //High speed Osc (> 4mhz)
//#FUSES XT
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOOSCSEN //Oscillator switching is disabled, main oscillator is source
#FUSES BROWNOUT //Reset when brownout detected
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES NOPUT //No Power Up Timer
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES LVP //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOCPD //No EE protection
#FUSES NOCPB //No Boot Block code protection
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#use delay(clock=20000000)
//#use RS232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,STREAM=LCD_UART)
#use RS232(baud=2400,parity=N,xmit=PIN_B6,rcv=PIN_B7,bits=8,STREAM=SW_UART)
#include <cMain.h>
//INITIALIZES PIC
void init(void)
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_low_volt_detect(FALSE);
setup_oscillator(False);
output_float(PIN_B2);
ext_int_edge(H_TO_L);
//enable_interrupts(INT_RDA);
//enable_interrupts(INT_EXT2);
//enable_interrupts(GLOBAL);
}
void main(void)
{
output_bit(PIN_D0,1);
output_bit(PIN_D1,0);
init();
while (1)
{
output_toggle(PIN_D1);
delay_ms(500);
output_toggle(PIN_D0);
printf("OK");
}
}
|
pic connected to max233cpp
siow.exe shows what is being sent:
júOKjúOKjúOK
I'm almost positive that it isn't software, but what on earth could be causing this? |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Tue Mar 20, 2007 9:52 am |
|
|
#FUSES LVP
Are you really programming in low voltage mode ?
Why do you redirect the UART output to:
STREAM=LCD_UART
STREAM=SW_UART
If then you use a single printf. This is inconsitent.
Delete the STREAM option or use fprintf and tell the compiler the output you are going to use.
Humberto |
|
|
grasspuddle
Joined: 15 Jun 2006 Posts: 66
|
|
Posted: Tue Mar 20, 2007 11:32 am |
|
|
i'll answer my own question.
the ground to the rs232 connector (pin5) was only ground about 60% of the time. Some third party board I was interfacing with had a pin I thought to be ground switch from ground to something else. Simply putting a wire from pin5 to the ground on my own board fixed the problem. The evil hardware strikes again.
thx for the reply humberto (LVP should've been NOLVP, sry) |
|
|
|
|
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
|