![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
Ok im having some trouble receiving from Hyper Terminal to my PIC18F1320. Im using BoostC to program/ I can send data out with no problem... Here is my receive code: Code: void RxRecv(char &MyTmp)
{
while(!pir1.RCIF);
MyTmp = rcreg;
Rs_Send(rcreg);
}
Code: while(1)
{
char Tmp2 = 0x00;
RxRecv(Tmp2);
}
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 28th June 2008 at 03:17 PM. | |
| |
| | #2 |
|
The argument of the function RxRecv() looks wrong to me. Does this work? Code: unsigned char MyTmp;
unsigned char RxRecv(){
while(!PIR1.RCIF);
return RCREG;
}
// ....
while(1){
MyTmp = RxRecv();
Rs_Send(MyTmp);
}
Last edited by eng1; 28th June 2008 at 03:43 PM. | |
| |
| | #3 | |
| Quote:
The (char *) tells the compiler to expect a pointer with the address of a char variable and &Tmp2 passes the address of the variable. Mike. Last edited by Pommie; 28th June 2008 at 04:14 PM. Reason: clarification. | ||
| |
| | #4 |
|
The actual issue is i cant seem to get passed the (bold): Code: void RxRecv(char *MyTmp)
{
while(!pir1.RCIF); //Not correctly checking Flag even with
//a breakpoint i cant skip this
*MyTmp = rcreg;
Rs_Send(rcreg);
}
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #5 |
|
Did you set bit CREN, that enables the reception?
| |
| |
| | #6 |
|
yes here is my full code: (still nothing) Code: #include <p1320.h>
#pragma CLOCK_FREQ 8000000
void Rs_Init()
{
//RS Init.
trisb = 0b00010010;
portb = 0x00;
spbrg = 0x0C;
txsta.BRGH = 0;
baudctl.BRG16 = 0;
txsta.SYNC = 0;
rcsta.SPEN = 1;
rcsta.CREN = 1;
txsta.TXEN = 1;
}
void Rs_Send (char tx_char)
{
while(!pir1.TXIF);
txreg = tx_char;
}
void puts(char *source)
{
while (*source != 0) // wait until tx register is empty
Rs_Send(*source++);
Rs_Send(0x0d);
Rs_Send(0x0a);
}
void RxRecv(char *MyTmp)
{
while(!pir1.RCIF); //Not correctly checking Flag even with
//a breakpoint i cant skip this
*MyTmp = rcreg;
Rs_Send(rcreg);
}
void main()
{
//PIC Init.
osccon.IRCF2 = 1; // 8Mhz Clock
osccon.IRCF1 = 1;
osccon.IRCF0 = 1;
Rs_Init();
puts("Hello, world\r\n");
while(1)
{
char Tmp2 = 0x00;
RxRecv(&Tmp2);
}
}
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 28th June 2008 at 06:52 PM. | |
| |
| | #7 |
|
You did not configured the A/D channels, did you? Try adding this line at the begining of the main function: Code: ADCON1 = 0xFF; | |
| |
| | #8 |
|
Does this work? Code: char Tmp2 = 0x00;
while (1) {
if (pir1.RCIF) {
Tmp2 = rcreg;
Rs_Send(Tmp2);
} // end if
} // end while
Last edited by BeeBop; 28th June 2008 at 08:45 PM. | |
| |
| | #9 | |
| Quote:
thanks a lot.
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | ||
| |
| | #10 |
|
Full Code Everything WORKING ! 100%
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
|
| Tags |
| 18f, boostc, usart |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| BoostC Charlieplexed PWM 32 | Mike, K8LH | Micro Controllers | 140 | 27th March 2009 11:19 AM |
| BoostC question.. AddressOf | Mike, K8LH | Micro Controllers | 8 | 25th June 2008 12:20 AM |
| LCD degree symbol with sprintf (BoostC) | futz | Micro Controllers | 29 | 5th June 2008 05:19 AM |
| math.h and lib for BoostC? | futz | Micro Controllers | 3 | 31st March 2008 06:29 AM |
| PIC USART: Help Please | mortuzahasan | Micro Controllers | 2 | 11th February 2007 07:28 PM |