Searching \ for ' [PIC] PIC C Compiler constants' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/languages.htm?key=c
Search entire site for: 'PIC C Compiler constants'.

No exact or substring matches. trying for part
PICList Thread
'[PICLIST] [PIC] PIC C Compiler Constants'
2001\05\25@065238 by Alvaro Deibe Diaz

flavicon
face
Hi all,

How can I do to make the line:

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\05\25@065656 by Alvaro Deibe Diaz

flavicon
face
Hi all,

How can I do to make the line:

SPBRG=FOSC/BAUD/16-1;

assign the correct value to SPBRG in Hi-Tech Pic C Compiler?

Actually it truncates the value of FOSC/BAUD/16, and I want the rounded
value.

I have defined FOSC and BAUD this way:
#define MHZ       *1000000
#define FOSC 4MHZ
#define BAUDIOS 28800

Thanks,

Alvaro

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam@spam@mitvma.mit.edu with SET PICList DIGEST in the body


2001\05\25@102057 by Andrew Warren

flavicon
face
Alvaro Deibe Diaz <PICLISTspamKILLspammitvma.mit.edu> wrote:

> How can I do to make the line:
>
> SPBRG=FOSC/BAUD/16-1;
>
> assign the correct value to SPBRG in Hi-Tech Pic C Compiler?
>
> Actually it truncates the value of FOSC/BAUD/16, and I want the
> rounded value.

Alvaro:

   SPBRG == (FOSC/BAUD/8 + 1)/2 - 1;

-Andy


=== Andrew Warren --- .....aiwKILLspamspam.....cypress.com
=== IPD Systems Engineering, CYSD
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspam_OUTspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body


2001\05\25@191230 by Brent Brown

picon face
Hi Alvaro,

The following works well for me, hope it works for you too (I'm sure
I originally got this from a Hi-Tech sample file but can't find it again
now). I put all the #defines in a header file serial.h and the init
routine and other serial stuff in serial.c. When I need to change
baud rate or crystal frequency for a project then I just need to edit
the values in the header file.

#define BAUD 2400               // Serial comms paramters for init
#define FOSC 1843200L
#define NINE_BITS 0             // Use 9bit comms? FALSE=8bit
#define HIGH_SPEED 0
#define DIVIDER ((int)(FOSC/(64UL * BAUD) -1)) // Divider for low speed
//#define DIVIDER ((int)(FOSC/(16UL * BAUD) -1)) // Divider for high speed

void InitComms(void){

       BRGH = HIGH_SPEED;
       SPBRG = DIVIDER;
       SYNC = 0;
       SPEN = 1;
       CREN = 1;
       SREN = 0;
       ADDEN = 0;
       TXIE = 0;                       // Disable Tx interrupt
       RCIE = 1;                       // Enable Rx interrupt
       TX9  = NINE_BITS;
       RX9  = NINE_BITS;
       TXEN = 1;
       TRISC7 = 1;
       TRISC6 = 1;
}

Brent Brown
Electronic Design Solutions
16 English Street
Hamilton, New Zealand
Ph/fax: +64 7 849 0069
Mobile/text: 025 334 069
eMail:  brent.brownspamspam_OUTclear.net.nz

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email @spam@listservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...