Ive tried to move data from Sbuf to Acc..... Ive tried using this code... whil;e debuggin the code ive used the serial window to pass data.... my main aim is to compare data that i recieve from the Rxd pin with memory
#include<stdio.h> #include<reg51f.h>
unsigned char c ;
char getchar() { while( RI != 0 ) { c = SBUF; RI = 0; } return(c); }
void main() { unsigned char b; b = getchar(); //printf("%c",&b );
B = b; }
ive also tried using _getkey().. and getchar directly.
So you've tried several things --- but you didn't say what happened.
And yes, you have to re-think what your getchar() function is doing. For starters: what do you think this function would do if you run it while there is no input available in SBUF?
And what will your main() do as it reaches its end?
ive tried using other registers as well as variables too.. but the result in all conditions is "0x000".
void recept() { // S0BUF = getchar();
dataio = _getkey(); B = dataio; // Check the value of dataio nd call appropriate functions
switch( SBUF ) { case 0x001: //dataio <= 0x000, to test first condition to run motor forward break; case 0x002: //dataio == 0x001, to test conditon 2, turn right // xmission(); break; case 0x003: //dataio == 0x002, to test condition 3, turn left break; case 0x004: // stop break; case 0x005: // increment speed break; case 0x006: // decrement speed break; case 0x007: // break!!!!!! break; case 0x008: // vision camera up smv_u(); break; case 0x009: // vision camera down smv_d(); break; case 0x00a: // vision camera right smv_r(); break; case 0x0b: // vision camera left smv_l(); break; case 0x0c: // mine plough down break; case 0x0d: // mine plough up break; } }
void main() {
initialize(); while(1) { if ( RI == 1 ) { recept(); }
if( P3 >= 0x08 ) // compare value in ADC register.. and send if value above threshold... testing left. :( { // testing by 26th march... :) xmission(); } }
}
and also
here: jnb Ri,detector mov a,sbuf call UartRecieve
but none of thse have helped me so far....
my aim is to recieve data from Rx and compare it to control a robot.
Please read the instructions on how to post source code: www.danlhenry.com/.../keil_code.png
Note that TABs don't work (well) - use spaces instead,
and don't forget to check it in the 'Preview'...
ive tried using other registers as well as variables too..
I ask again: Are you programming in C or not? Stay away from any processor registers when you program in C. It is only the SFR and ordinary, plain, boring C variables you should think about. C is a "complete" language so a normal user can manage just about anything without the need for assembler.
#include<stdio.h> #include<reg51f.h> void recept() { // S0BUF = getchar(); dataio = _getkey(); B = dataio; // Check the value of dataio nd call appropriate functions switch( SBUF ) { case 0x001: //dataio <= 0x000, to test first condition to run motor forward break; case 0x002: //dataio == 0x001, to test conditon 2, turn right // xmission(); break; case 0x003: //dataio == 0x002, to test condition 3, turn left break; case 0x004: // stop break; case 0x005: // increment speed break; case 0x006: // decrement speed break; case 0x007: // brake!!!!!! break; case 0x008: // vision camera up smv_u(); break; case 0x009: // vision camera down smv_d(); break; case 0x00a: // vision camera right smv_r(); break; case 0x0b: // vision camera left smv_l(); break; case 0x0c: // mine plough down break; case 0x0d: // mine plough up break; } } void main() { initialize(); while(1) { if ( RI == 1 ) { recept(); } }
Im tryin to use registers just to check values.. otherwise register are not used in my code I am declarling variables... I am using 'C' language, Sorry for confusing you last time.... :) Thnaks for replying :)
yes i have same problem last time and got error.
when you have the answer pleaze post for him and error can be removed from file.
with c i said acc can error for others.
View all questions in Keil forum