![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
hello i use pbpdemo compiler but when i compile my program too hex and write it to chip program doesnt work properly i use epic for write hex file my basic program and my hex file are here, is it true compile for this basic program? i think my compiler doesent work properly.( i writ program for 16F84 or 16F84A ) ' 'FIRST BASIC PROGRAM TO WINK TWO LED'S CONNECTED TO PORT B LOOP:HIGH 0 'TURN ON LED CONNECTED TO PIN RB0 PAUSE 500 'DELAY FOR .5 SECONDS LOW 0 'TURN OFF LED CONNECTED TO PIN RBO PAUSE 500 'DELAY FOR .5 SECOND GOTO LOOP 'GO BACK TO LOOP AND BLINK & WINK LED'S FOREVER END :1000000028288F018E00FF308E07031C8F07031CEA :10001000232803308D00DF300F2003288D01E83EB8 :100020008C008D09FC30031C18288C070318152838 :100030008C0764008D0F15280C181E288C1C222894 :1000400000002228080083130313831264000800B1 :10005000061483160610831201308F00F43002203C :10006000061083160610831201308F00F430022030 :0600700028286300392876 :02400E00FD3F74 :00000001FF thank you | |
| |
| | #2 |
|
I've never used PIC Basic, so I could be wrong. But just taking a look at the code, I'm seeing things missing that I would think would need to be present in any language for the pic. There is no where that you tell it to set up any Port B pins as output. All pins are defaulted to input until explicitly told to be output. Secondly, when you issue the command HIGH 0 and LOW 0, are those supposed to have pin numbers specified? Like should it be HIGH RB0, LOW RB0? just saying HIGH 0 and LOW 0 seems ambiguous, as Port A and Port B both have pin 0's. It goesn't look like you are specifying anything at all for ports.
| |
| |
| | #3 |
|
Navid I haven't tried this but it did compile OK. Try the following code. Code: DEVICE = 16F84A 'tell the compiler what device you are using XTAL = 4 'tell the compiler what crystal you are using OUTPUT PORTB 'set portb to output LOW PORTB.0 'set portb bit 0 low LOW PORTB.1 'set portb bit 1 low BLINK: HIGH PORTB.0 'set portb bit 0 high turning on led DELAYMS 500 'delay for 1/2 sec LOW PORTB.0 'set portb bit 0 high turning off led HIGH PORTB.1 'set portb bit 1 high turning on led DELAYMS 500 'delay for 1/2 sec LOW PORTB.1 'set portb bit 1 high turning off led DELAYMS 500 'delay for 1/2 sec GOTO BLINK 'go back and loop forever END
__________________ I like to tell people I have the heart of a young boy. Then I say it\'s in a jar on my desk. - Stephen King | |
| |
| | #4 |
|
Navid, Your Picbasic code is OK. high 0 sets portB.0 high, etc. Note: This method only applies to portB pins. PortA must be set by defining and using the portA/trisA registers. You haven't set the two pins used as outputs. To set b0 & b1 as outputs simply add "dirs = %00000011" before the start of the action. ( 0 = input, 1 = output) PortB pins could also be set up using the same method as portA - i.e. using portB/trisB registers - but it's simpler to use "dirs =% ........ " . Your code only sets b0 - there is no mention of b1, except in your circuit. Try this: dirs = %00000011 ' set b0,b1 as outputs loop: high 0 ' turn on LED1 pause 500 ' delay 500ms low 0 ' turn off LED1 high 1 ' turn on LED2 pause 500 ' delay 500ms low 1 ' turn off LED2 goto loop ' do it all over again forever end hope that helps, kenmac | |
| |
|
| Tags |
| compiler, pic |
| Thread Tools | |
| Display Modes | |
| |