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.
|
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? |
|
|
|
--- 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? |