|
|
View previous topic :: View next topic |
Author |
Message |
Scottl
Joined: 21 Feb 2005 Posts: 25
|
USART Question? |
Posted: Mon Feb 21, 2005 11:07 am |
|
|
I am new to CCS and cannot get the code below to work! I have the same hardware sending data from a program that was generated from PicBasic and everything works fine. So I think the only thing is I am missing something in my CCS Code.
Can someone look at my code below and tell me what I am doing wrong?
#include <16F876A.h>
#device *=16
#device adc=8
#use delay(clock=20000000)
#fuses NOWDT,XT, NOPUT, NOPROTECT, BROWNOUT, LVP, NOCPD, NOWRT, NODEBUG
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8, ERRORS)
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
while(TRUE)
printf("test");
}
Thanks in advance, Scott |
|
|
Ttelmah Guest
|
|
Posted: Mon Feb 21, 2005 11:17 am |
|
|
Two comments. What is connected to RB3?. You have enabled LVP mode, and if this pin is not pulled low, the chip won't run. Add the line:
SETUP_COMPARATOR(NC_NC_NC_NC);
The 876A, has the comparator module, and this tends to default to enabled.
Otherwise, what you have posted, looks to me like it should work.
Best Wishes |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Feb 21, 2005 11:55 am |
|
|
One additional remark:
Your clockspeed is set to 20MHz, this requires a '#fuse HS' setting i.s.o. XT. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 21, 2005 12:24 pm |
|
|
For the 16F877A, Microchip tried to make it be compatible with the 16F877
so they have the comparators turned off by default on this chip.
I suggest you try a more simple program. Get rid of all the stuff
that you don't need. Change the fuses as the others suggested.
So just copy the following program into MPLAB and try it.
Code: | #include <16F876A.h>
#use delay(clock=20000000)
#fuses HS, NOWDT, NOPROTECT, PUT, BROWNOUT, NOLVP
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
void main()
{
while(TRUE)
{
printf("test ");
}
} |
|
|
|
|
|
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
|