Apr 26, 2013 #1 Y yamine Member level 1 Joined May 4, 2012 Messages 37 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,286 Activity points 1,507 Hi, how can i program a PIC Microcontroller in assembly and c in the same time ? can you give me an example? thank you,
Hi, how can i program a PIC Microcontroller in assembly and c in the same time ? can you give me an example? thank you,
Apr 26, 2013 #2 S spudboy488 Full Member level 5 Joined Oct 10, 2012 Messages 272 Helped 69 Reputation 140 Reaction score 76 Trophy points 1,308 Activity points 3,059 How it's done varies depending on the compiler you are using. Look up "in-line assembly" for your c-compiler to see how it's done.
How it's done varies depending on the compiler you are using. Look up "in-line assembly" for your c-compiler to see how it's done.
Apr 26, 2013 #3 Y yamine Member level 1 Joined May 4, 2012 Messages 37 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,286 Activity points 1,507 i will use mplab, but i don't have any idea
Apr 27, 2013 #4 R RoboticsGuy Junior Member level 3 Joined Aug 15, 2009 Messages 26 Helped 8 Reputation 16 Reaction score 5 Trophy points 1,283 Location USA Activity points 1,419 It's really easy to use inline assembly in MPLAB, but it depends on which compiler you are using. Assuming you are using C18, check out section 2.8.2 "Inline Assembly" in the C18 Compiler Users Guide: https://ww1.microchip.com/downloads/en/devicedoc/51288f.pdf As the users guide explains, all you have to do is wrap the inline assembly with "_asm" and "_endasm" tags. Example from the users guide: Code: _asm /* User assembly code */ MOVLW 10 // Move decimal 10 to count MOVWF count, 0 /* Loop until count is 0 */ start: DECFSZ count, 1, 0 GOTO done BRA start done: _endasm I hope this helped!
It's really easy to use inline assembly in MPLAB, but it depends on which compiler you are using. Assuming you are using C18, check out section 2.8.2 "Inline Assembly" in the C18 Compiler Users Guide: https://ww1.microchip.com/downloads/en/devicedoc/51288f.pdf As the users guide explains, all you have to do is wrap the inline assembly with "_asm" and "_endasm" tags. Example from the users guide: Code: _asm /* User assembly code */ MOVLW 10 // Move decimal 10 to count MOVWF count, 0 /* Loop until count is 0 */ start: DECFSZ count, 1, 0 GOTO done BRA start done: _endasm I hope this helped!
Apr 27, 2013 #5 Y yamine Member level 1 Joined May 4, 2012 Messages 37 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,286 Activity points 1,507 i found this example in the Users Guide, it resolve my problem thank you for helping
Apr 30, 2013 #6 R RoboticsGuy Junior Member level 3 Joined Aug 15, 2009 Messages 26 Helped 8 Reputation 16 Reaction score 5 Trophy points 1,283 Location USA Activity points 1,419 yamine said: i found this example in the Users Guide, it resolve my problem thank you for helping Click to expand... You're welcome! Good luck with your project!
yamine said: i found this example in the Users Guide, it resolve my problem thank you for helping Click to expand... You're welcome! Good luck with your project!