|
|
View previous topic :: View next topic |
Author |
Message |
adrianrb Guest
|
16F628 inicialization |
Posted: Wed Jan 10, 2007 11:47 am |
|
|
Hi all.
I´ve trying to make some codes work on my 16F628 chip, but
noting happens... I saw in the microchip forum that chip needs
some initialization (source is in assembler, below).
Could someone translate (and explain, if possible) them to C
in order I use them in my sources? (I´m new in PIC world)
Tks in advance,
Adrian
Code (in asm)... 8-/
<pre>
MOVLW 0
MOVWF RCSTA
MOVLW B'00000111'
MOVWF CMCON
BSF STATUS,RP0
MOVLW 0
MOVWF TXSTA
MOVLW 0
MOVWF PIE1
BCF STATUS,RP0
BSF STATUS,RP0 ;PULL UPS DO PORTB ESTAO OFF (BIT7=1)
MOVLW B'10010111' ;COLOCA PREESC. EM 256 NO TMR0
MOVWF OPTION_REG
BCF STATUS,RP0
MOVLW B'00000000'
MOVWF INTCON
</pre> |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jan 10, 2007 12:35 pm |
|
|
Do you have the CCS compiler ? This forum is about that compiler.
You don't need to do any initialization in ASM code with the CCS
compiler. In some cases, the compiler will automatically insert code
to do the proper initialization. It will do this if you tell it to load the
library code to run a particular module, such as the serial port.
In other cases, you can call a CCS function to enable the Port B pull-ups.
But you don't need ASM code to do this.
If you don't have the CCS compiler, then you should ask the questions
on the MPLAB forum.
Here's a test program for the 16F628 written in CCS. It blinks an
LED on pin B0. It assumes you have a 4 MHz crystal, and that all
the other necessary connections are made (such as a pull-up resistor
on the MCLR pin, etc.)
Code: |
#include <16F628.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
//========================
void main()
{
while(1)
{
output_high(PIN_B0);
delay_ms(500);
output_low(PIN_B0);
delay_ms(500);
}
} |
|
|
|
|
|
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
|