Sign in

username:

password:



Not a member?

Search piclist



Search tips

Subscribe to piclist



piclist by Keywords

12F675 | 16F628 | 16F84 | 16f877 | 16F877A | 16F88 | 18F458 | ADC | AVR | Bootloader | CAN | CCS | CRC | EAGLE | EEPROM | ICD | ICSP | IDE | JDM | LED | Macros | Microchip | MPLAB | PCB-CAD | PIC10F | Pic12f675 | PIC16F84 | PIC16F84A | PIC16F877 | PIC18 | PIC18F452 | PicBasic | PICC | PICSTART | PWM | RS-485 | RS232 | SMT | SPI | UART | USART | USB | Wireless | Wisp628 | Xilinx

Ads

Discussion Groups

Discussion Groups | Piclist | College student - Need help badly, please?

A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.

College student - Need help badly, please? - devonsc - Nov 29 12:34:00 2004



Hi there,

I'm a newbie in using PIC microcontroller. Currently, implementing a
PIC microcontroller unit (PIC 16F876) for a project.

There are a few matters where I have doubts in after referring to
the datasheet of this PIC unit. If its not too much trouble, can
anyone explain briefly regarding the difference of the following?
Hope you guys dont mind. Help really needed. Thanks in advance...

a.) Do you guys mind explaining the difference between RTCC (Real
Time Clock Counter) and WDT (Watch Dog Timer)?

b.) Do you guys mind explaining the difference between the
subroutines and macros?

Please? Thanks in advance. Help needed badly...Please?






(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )


Re: College student - Need help badly, please? - rtstofer - Dec 4 15:07:00 2004


--- In , "devonsc" <devonsc@y...> wrote: > Hi there,
>
> I'm a newbie in using PIC microcontroller. Currently, implementing
a
> PIC microcontroller unit (PIC 16F876) for a project.
>
> There are a few matters where I have doubts in after referring to
> the datasheet of this PIC unit. If its not too much trouble, can
> anyone explain briefly regarding the difference of the following?
> Hope you guys dont mind. Help really needed. Thanks in advance...
>
> a.) Do you guys mind explaining the difference between RTCC (Real
> Time Clock Counter) and WDT (Watch Dog Timer)?
>
RTCC is a timer or up-counter usually based on the clock frequency
of the device. Sometimes a RTCC will use an external clock
frequency but, functionally, it doesn't matter. Time on a RTCC is
usually in ticks (or counts) but it is sometimes converted to
hours:minutes:seconds.

A WDT is simply a timeout counter. It is periodically reset in code
and, if allowed to time out, will reset the processor. The thought
is that the code must be hung up or the system somehow
malfunctioning and the hope is that a reset will clear the problem.

> b.) Do you guys mind explaining the difference between the
> subroutines and macros?

A subroutine is a block of code that, in some languages, can take
and operate on parameters. If a subroutine returns a result (other
than by modifying the parameters) it is a function. Generally,
subroutines are written when the code will be called from more than
one place withing the main code. Other uses for subroutines are in
the form of a library of canned code - getting and sending
characters for example.

A macro is simply a scheme for substituting text - replacing one
string of text with another. Macros are frequently used in C to
provide conditional code. Macros are also used in assembly language
to define higher level constructs or new language elements.

SPI_Clk_bit equ 0x80 ; PORTB bit 7
SPI_CS_n_bit equ 0x40 ; PORTB bit 6
SPI_DataOut_bit equ 0x20 ; PORTB bit 5
H equ 1 ; logic levels for macros
L equ 0
SPI_TRIS equ 0x1F ; TRISB

PORTBi equ 0x0020 ; internal copy of PORTB

SPI_Macro MACRO Signal, Level
movf PORTBi,W
if Level == H
iorlw Signal
else
if Level == L
andlw ~Signal
else
error "Invalid signal"
endif
endif
movwf PORTBi
movwf PORTB

if UseDelay
call Delay
endif

ENDM

SPI_Clk MACRO Level
SPI_Macro SPI_Clk_bit,Level
ENDM

SPI_CS_n MACRO Level
SPI_Macro SPI_CS_n_bit,Level
ENDM

SPI_DataOut MACRO Level
SPI_Macro SPI_DataOut_bit,Level
ENDM

Given these macros it is possible to code the signal transitions on
the SPI lines as:

SPI_CS_n H ; set SPI_CS_n high while
clock is high
SPI_Clk L ; then set clock low
SPI_DataOut L ; no particular reason

The macro itself is just a text substitution engine; in the end the
output is assembly code as emitted by SPI_Macro. The other 3 macros
just set up the signal names. > Please? Thanks in advance. Help needed badly...Please?





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )