0
\$\begingroup\$

I have been using PIC microcontrollers and have been using MikroC for the programming but I am little bit confused about the ports. On a PIC16F84A the port is defined in mikroC as TRISA = 0xFF, and a bit of the port can be accessed by PORTA.f0. But for other microcontrollers in the series a different code is used. For example, TRISIO = 0xFF.

Can you please explain to me how I can know the code for accessing the ports that applies for every microcontroller out there? Also the input for a PIC is 1 and output is 0, and for Atmel the input 0 and output 1 which I found confusing if someone can explain?

\$\endgroup\$
1
  • 3
    \$\begingroup\$ Please consider making your question title more specific, as it stands "Help with microcontrollers" could be any one of a thousand questions. Bear in mind others who come along with the same problem and would never find this question due to a bad title. It's also considered bad to ask two questions in one post, better to ask seperate questions so that each answer can be voted on it's merits. \$\endgroup\$
    – Martin
    Commented Jul 9, 2013 at 9:03

3 Answers 3

1
\$\begingroup\$

Try looking at the header files you're using, or like Scott Seidman mentioned the compiler datasheet

Microcontrollers datasheet aren't always going to have the exact variable names used in program (maybe in MPLAB) but most likely not in 3rd-party IDE like MikroC

MikroC Manual for PIC12, 16 and 18

\$\endgroup\$
3
\$\begingroup\$

You just have to read the datasheet of each microcontroller that you are using. Which is something you should do for every device that you are using, anyway.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ The question has much more to do with how the individual compiler sets up each uC than with the uC itself. \$\endgroup\$ Commented Jul 9, 2013 at 10:39
0
\$\begingroup\$

I don't use MikroC, which looks like a fine compiler, but many compilers put all the chip-related info into a header file which is compiled into your code via an #include statement, or some such.

Open the header file, and scan it for port information.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.