I am starting learning about PIC microcontroller. but i am in confusion about which MC i choose 16 series or 18.
please help me to choose right one. And what is the difference between them.And where can i get about that MC?
U may start learning about microcontroller with 16F especially 16F877A (40 pin), many courses starts with this pic or even with 16f628a (20 pin).
There's no big differences between 16F and 18F series, except that 18F has more features than 16F...
i paid only 20 bucks for 20 pic16f877a on ebay.very good deal.Old PIC16F84A for example have more available examples and tutorials, but price is around 5-6eur (in my country price is catastrophic around 10eur :shock
:wink:
i paid only 20 bucks for 20 pic16f877a on ebay.very good deal.
i paid only 20 bucks for 20 pic16f877a on ebay.very good deal.
I'm sorry guys, i made a mistake.I paid 20 bucks for 10 chips not 20 as i motioned before.
here's a link to ebay
**broken link removed**
PIC Specifics
In order to get the most from your mikroC PRO for PIC compiler, you should be familiar with certain aspects of PIC MCU. This knowledge is not essential, but it can provide you a better understanding of PICs’ capabilities and limitations, and their impact on the code writing.
Types Efficiency
First of all, you should know that PIC’s ALU, which performs arithmetic operations, is optimized for working with bytes. Although mikroC PRO for PIC is capable of handling very complex data types, PIC may choke on them, especially if you are working on some of the older models. This can dramatically increase the time needed for performing even simple operations. Universal advice is to use the smallest possible type in every situation. It applies to all programming in general, and doubly so with microcontrollers.
Get to know your tool. When it comes down to calculus, not all PIC MCUs are of equal performance. For example, PIC16 family lacks hardware resources to multiply two bytes, so it is compensated by a software algorithm. On the other hand, PIC18 family has HW multiplier, and as a result, multiplication works considerably faster.
Nested Calls Limitations
Nested call represents a function call within function body, either to itself (recursive calls) or to another function. Recursive function calls are supported by mikroC PRO for PIC but with limitations. Recursive function calls can't contain any function parameters and local variables due to the PIC’s stack and memory limitations.
mikroC PRO for PIC limits the number of non-recursive nested calls to:
8 calls for PIC12 family,
8 calls for PIC16 family,
16 calls for PIC16 Enhanced family.
31 calls for PIC18 family.
Note that some of the built-in routines do not count against this limit, due to their “inline” implementation.
Number of the allowed nested calls decreases by one if you use any of the following operators in the code: * / %. It further decreases if you use interrupts in the program. Number of decreases is specified by number of functions called from interrupt. Check functions reentrancy.
If the allowed number of nested calls is exceeded, the compiler will report a stack overflow error.
PIC18FxxJxx Specifics
Shared Address SFRs
mikroC PRO for PIC does not provide auto setting of bit for acessing alternate register. This is new feature added to PIC18fxxJxx family and will be supported in future. In several locations in the SFR bank, a single address is used to access two different hardware registers. In these cases, a “legacy” register of the standard PIC18 SFR set (such as OSCCON, T1CON, etc.) shares its address with an alternate register. These alternate registers are associated with enhanced configuration options for peripherals, or with new device features not included in the standard PIC18 SFR map. A complete list of shared register addresses and the registers associated with them is provided in datasheet.
PIC16 Specifics
Breaking Through Pages
In applications targeted at PIC16, no single routine should exceed one page (2,000 instructions). If routine does not fit within one page, linker will report an error. When confront with this problem, maybe you should rethink the design of your application – try breaking the particular routine into several chunks, etc.
Limits of Indirect Approach Through FSR
Pointers with PIC16 are “near”: they carry only the lower 8 bits of the address. Compiler will automatically clear the 9th bit upon startup, so that pointers will refer to banks 0 and 1. To access the objects in banks 2 or 3 via pointer, user should manually set the IRP, and restore it to zero after the operation. The stated rules apply to any indirect approach: arrays, structures and unions assignments, etc.
Note :
It is very important to take care of the IRP properly, if you plan to follow this approach. If you find this method to be inappropriate with too many variables, you might consider upgrading to PIC18.
If you have many variables in the code, try rearranging them with the linker directive absolute. Variables that are approached only directly should be moved to banks 3 and 4 for increased efficiency.
PIC16 Enhanced Family Specifics
PIC16 Enhanced family has 16-bit FSRs, FSRxL and FSRxH, capable of accessing entire RAM and Flash memory.
This makes pointers to constants and pointers to variables compatible.
Linear Data Memory
The Linear Data Memory is a memory space consisted of GPRs (each 80 bytes in size) located in every bank. Together, they form a linear, continuous, memory area and allow large stacks, arrays, buffers, etc.
This means that there are no gaps between the end of GPR in one bank and the beginning of the next GPR in the following bank.
To use this memory space, ldm memory specifier must be used.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?