BrunoG Site Admin
Joined: 22 Nov 2005 Posts: 636
|
Posted: Tue Oct 03, 2006 1:17 am Post subject: |
|
|
Hi,
with EasyPic3, PIC12F675 @8Mhz (crystal) :
remove JP5 & JP6 jumpers
connect one wire from JP5 RX (left side) to RA0 on PORTA/GP connector
connect one wire from JP6 TX (left side) to RA1 on PORTA/GP connector
connect JP15 jumper (AN2 pot)
flash your pic with this program example (should fit within mikroC demo limit if you don't have a licence key) :
| Code: | void Com_Write(char *s)
{
while(*s)
{
Soft_Uart_Write(*s++) ;
}
}
void Com_ConstWrite(const char *s)
{
while(*s)
{
Soft_Uart_Write(*s++) ;
}
}
void main()
{
GPIO = 1 ;
CMCON = 7 ;
ANSEL = 0b100 ;
TRISIO = 0b101 ;
Soft_Uart_Init(GPIO, 0, 1, 9600, 0) ;
Delay_ms(1) ;
Com_ConstWrite("\r\n\n\nWelcome, strike any key to read AN2>") ;
for(;;)
{
unsigned char c, r ;
unsigned int v ;
c = Soft_Uart_Read(&r) ;
if(!r)
{
char str[10] ;
v = Adc_Read(2) ;
WordToStr(v, str) ;
Com_Write(str) ;
Com_ConstWrite("\r\n>") ;
}
}
} |
connect a terminal to EasyPic3 RS232 comm. connector (as windows hyperterminal for example), 9600-8-N-1
you should get a welcome message, then strike a key to read AN2 value.
That's all ! _________________ BrunoG, Administrator |
|