pravin b
Member level 5
- Joined
- May 20, 2012
- Messages
- 85
- Helped
- 2
- Reputation
- 4
- Reaction score
- 1
- Trophy points
- 1,288
- Location
- Mumbai, India
- Activity points
- 2,083
How can I pass the the microcontroller port to a function? for example my task is to flash PORTC with some delay using PIC16F1939.
However with the above written code I am not able to get the results. Is there any method to do so? Any further reading?
Code:
#include <htc.h>
__CONFIG(FOSC_INTOSC & WDTE_OFF & PWRTE_OFF & MCLRE_ON & CP_ON & CPD_OFF & BOREN_ON & CLKOUTEN_OFF & IESO_OFF & FCMEN_OFF);
__CONFIG(WRT_OFF & VCAPEN_OFF & PLLEN_ON & STVREN_ON & BORV_HI & LVP_ON);
#define LEDPORT PORTC
void systeminit()
{
OSCCON = 0b01110000; // 32 MHz Fosc w/ PLLEN_ON (config bit)
TRISC=0x00;
}
void delay(unsigned int count)
{
unsigned int i,j;
for(i=0;i<=count;i++)
for(j=0;j<=548;j++);
}
void flashport(unsigned char oport)
{
oport=0x00;
delay(100);
oport=0xFF;
delay(100);
}
void main()
{
systeminit();
while(1)
flashport(LEDPORT);
}
However with the above written code I am not able to get the results. Is there any method to do so? Any further reading?
Last edited: