View previous topic :: View next topic |
Author |
Message |
ljbeng
Joined: 10 Feb 2004 Posts: 205
|
PCD: printf and putc in 4.096 |
Posted: Thu Aug 13, 2009 2:12 pm |
|
|
I have a simple program running just to see if my ccs development board is working. I used the pic24 wizard to get most of this and added the putc in there.
Code: |
#include <24FJ128GA006.h>
#device icd=true
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOJTAG //JTAG disabled
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES ICSP2 //ICD uses PGC2/PGD2 pins
#FUSES WINDIS //Watch Dog Timer in non-Window mode
#FUSES WPRES128 //Watch Dog Timer PreScalar 1:128
#FUSES WPOSTS16 //Watch Dog Timer PostScalar 1:32768
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES FRC_PS //Fast RC Oscillator with Post Scaler
#FUSES NOCKSFSM //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES NOOSCIO //OSC2 is clock output
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#use delay(clock=20000000,RESTART_WDT)
#use rs232(uart1,baud=9600,parity=N,bits=8)
void main()
{
setup_spi(SPI_SS_DISABLED);
setup_spi2(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer1(TMR_DISABLED|TMR_DIV_BY_1);
p:
//putc('A');
//putc(0x13);
//putc(0x10);
putc(0xaa);
delay_ms(1);
goto p;
// TODO: USER CODE!!
}
|
I am not getting any data that makes sense in SIOW. If I look at on scope the 1's are around .54ms wide. So I put a special baud rate of 1851baud in SIOW and I can sometimes see 0xAA in my data window. What can I be doing wrong here? Thanks. |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Aug 13, 2009 3:42 pm |
|
|
Your current oscillator setting is "Fast RC Oscillator with Post Scaler", so the clock frequency can never be 20 MHz. #FUSES PR or PR_PLL selects the primary oscillator. |
|
|
Guest
|
|
Posted: Fri Aug 14, 2009 12:40 pm |
|
|
Hi
Hints
Remove both:
Code: | setup_spi(SPI_SS_DISABLED);
setup_spi2(SPI_SS_DISABLED);
|
|
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Fri Aug 14, 2009 1:08 pm |
|
|
The said setup_spi() statemenst are actually enabling the SPI interface, which is most likely unintended. But they are of course not related to the reported baud rate issues. |
|
|
|