Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

uart bit banging

Status
Not open for further replies.
not really any code specifically , just a working example of how to insert asm,

XC8 btw...

Code:
int main(int argc, char** argv)
{   
while (1){
#asm
   movlw 0x17
   movwf  Count
#endasm
}
}
 
Right! Well first off embedded main() has no parameters..... its void.

void main(void).. Reason... PC programs can be run with parameters and switches and embedded programs can not..

Funny thing is... That pic16's require the main to have no return, but pic18's do require a return... Weird as both do not need a return!!!

Count must be declared global and asm must use the underscore to access it.

C:
char Count;
void main(void)
   { 
   while (1)
      {
      #asm
           movlw 0x17
           movwf _Count
      #endasm
      }
  }
 
I often wondered that about calling main, I realize that there is not much parameters being passed in to main, and not much to return to... I meant to ask if there was something that may get&set those values but never got around to it,
I found it in a web example, however it has never caused a build error,

got it, count is Global!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top