www.micro-examples.com
Microcontroller circuits and source code examples
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 

A2D and RS232

 
Post new topic   Reply to topic    www.micro-examples.com Forum Index -> General Discussion About PIC Microcontrollers
View previous topic :: View next topic  
Author Message
ager



Joined: 02 Oct 2006
Posts: 1

PostPosted: Mon Oct 02, 2006 9:13 pm    Post subject: A2D and RS232 Reply with quote

Hello
I am using 12f675 chip.
I need one RS232 rx and tx pins on EasyPIC3 board and A/D converter converts 0-5V Analog input to Digital data and send to the RS232 out when RS232 request data. How i configure EasyPIC3 board setting please.
Regards

Ager
Back to top
View user's profile Send private message
BrunoG
Site Admin


Joined: 22 Nov 2005
Posts: 636

PostPosted: Tue Oct 03, 2006 1:17 am    Post subject: Reply with quote

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 Wink !
_________________
BrunoG, Administrator
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    www.micro-examples.com Forum Index -> General Discussion About PIC Microcontrollers All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2005 phpBB Group