Jump to content

j3n4

EstablishedMember
  • Content Count

    13
  • Joined

  • Last visited

Everything posted by j3n4

  1. hi, i have solved. here is the code: #include <system.h> // 4.0 Mhz #pragma CLOCK_FREQ 4000000 #define FOSC 4000000 #define spBAUD 9600 #define fSPBCLK (FOSC) // UART Baud rate generator clock (high speed) // #define fSPBCLK (FOSC / 4) // UART Baud rate generator clock (low speed) #define SPBRG_VAL ((fSPBCLK / (spBAUD * 16L)) - 1L) // bit_time FOSC / 4 / BAUDRATE #define bit_time 104 // 9600 baud at 4MHz // Hardware dependant defines RC6 & 7 #define RX_PIN 7 #define TX_PIN 6 //Target PIC16F877 configuration word #pragma DATA _CONFIG, _PWRTE_ON & _BODEN_ON & _WDT_OFF & _LVP_ON & _CPD_OFF & _DEBUG_OFF & _XT_OSC & _CP_OFF // PIC16F87X defaults for hardware USART support // DS30292C-page 95 (TX) & DS30292C-page 104 (RX) #define TX_PORT PORTC #define TX_TRIS TRISC #define TX_BIT TX_PIN #define RX_PORT PORTC #define RX_TRIS TRISC #define RX_BIT RX_PIN #define e_SPBRG SPBRG #define e_RCREG RCREG #define e_TXREG TXREG #define e_TXSTA TXSTA #define e_RCSTA RCSTA #define e_TXIF_PIR PIR1 #define e_RCIF_PIR PIR1 #define e_TXIF_BIT TXIF #define e_RCIF_BIT RCIF #define MODE (USART_reset_wdt | USART_HW) #define bit_time 104 // 9600 baud at 40MHz #include "rs232_driver.h" void interrupt( void ) { } void main( void ) { // RS232 Communications uart_init(1,SPBRG_VAL); // set high speed divisor mode and divisor value - 9600 puts("PIC16F877A test"); delay_ms(100); while (1){ if (kbhit()){ putc(getc()); } } } This was the problem: #define MODE (USART_reset_wdt) Now whit this : #define MODE (USART_reset_wdt | USART_HW) It work fine. Best reguards j3n4
  2. AH! I forgot to say: I am using 16F876 pic with external 4Mhz crystal. If you need i can post the circuit scheme. Reguards j3n4
  3. Hi, for some days I am trying to interfacing the serial port of my computer on max232 of my pic. I built (I hope), all ok but I have some doubts on the code. I have read a bit on the topics of this forum and I have copied a bit of code but its does not work. Somebody can help me? Here's the code: #include <system.h> #pragma CLOCK_FREQ 4000000 //Target PIC16F877 configuration word #pragma DATA _CONFIG, _PWRTE_ON & _BODEN_ON & _WDT_OFF & _LVP_ON & _CPD_OFF & _DEBUG_OFF & _XT_OSC & _CP_OFF // Sample PIC16F87x defaults for software emulated USART support #define TX_PORT 0x07 #define TX_TRIS 0x87 #define TX_BIT 6 #define RX_PORT 0x07 #define RX_TRIS 0x87 #define RX_BIT 7 #define e_SPBRG 0x99 #define e_RCREG 0x1a #define e_TXREG 0x019 #define e_TXSTA 0x98 #define e_RCSTA 0x18 #define e_TXIF_PIR 0x0c #define e_RCIF_PIR 0x0c #define e_TXIF_BIT 4 #define e_RCIF_BIT 5 #define MODE (USART_reset_wdt) #define bit_time 104 // 9600 baud at 40MHz #include "rs232_driver.h" void interrupt( void ) { } void main( void ){ trisc = 0x80; portc = 0x00; uart_init(1,25); // set high speed divisor mode and divisor value - 9600 puts("Hello, world"); while (1){ if (kbhit()){ putc(getc()); } } } Reguards j3n4
  4. True, but the result its the same with adjustment. My procedure is wrong. I resolved with this code: // Read A0 for desired setpoint adcon0 = 10000001b; // Wait the required acquisition time (datasheet) delay_10us(2); //set_bit(adcon0, 2); // OUTER GATES // Start the conversion adc_go = 1; // Wait until it is done while (adc_go); retval = (short)adresh; retval = retval << 8; retval |= adresl; Now work fine. Best Reguards j3n4
  5. Hi, im wrote a little test program to read ADC and out the result on LCD. He works fine in emulator but when i try on my Hardware it does not work. He print the "BootUp..." Message and stop. I think ADC read is wrong but im not have any ideas. Can you help me? #include <system.h> // Add the following after #include <system.h> in you source file: // #define LCD_ARGS 2, 1, PORTB, TRISB, PORTC, TRISC, 3, 2, 1 // #include <lcd_driver.h> // include the LCD template code //Target PIC16F84 configuration word #pragma DATA _CONFIG, _PWRTE_OFF & _WDT_OFF & _XT_OSC & _CP_OFF //Set clock frequency #pragma CLOCK_FREQ 4000000 void interrupt( void ) { //Handle timer0 interrupt if( intcon & (1<<T0IF) ) { clear_bit( intcon, T0IF ); //clear timer 0 interrupt bit } } void main( void ) { volatile bit A2D_not_done@0x0FC2.2; // bit 2 of adcon0 //Configure port A trisa = 11111111b; // ALL PORT A inputs //Configure port B trisb = 00000000b; //set portb as output. //Configure port B trisc = 00000000b; //set portb as output. //Initialize port B portb = 0; //Initialize port C portc = 0; // initialize ADC adcon1 = 00000010b; //Set Timer0 mode clear_bit( option_reg, T0CS ); //configure timer0 as a timer //Set prescaler assignment clear_bit( option_reg, PSA ); //prescaler is assigned to timer0 //Set prescaler rate clear_bit( option_reg, PS2 ); //prescaler rate 1:2 clear_bit( option_reg, PS1 ); clear_bit( option_reg, PS0 ); //Set timer0 source edge selection set_bit( option_reg, T0SE ); //increment on high-to-low transition on RA4/T0CKI pin //Set timer 1 prescaler rate clear_bit( t1con, T1CKPS1 ); //prescaler rate 1:1 clear_bit( t1con, T1CKPS0 ); //Set timer 1 mode clear_bit( t1con, TMR1ON ); //disable timer 1 //Set timer 2 prescaler rate clear_bit( t2con, T2CKPS1 ); //prescaler rate 1:1 clear_bit( t2con, T2CKPS0 ); //Set timer 2 postscaler rate clear_bit( t2con, TOUTPS3 ); //postscaler rate 1:1 clear_bit( t2con, TOUTPS2 ); clear_bit( t2con, TOUTPS1 ); clear_bit( t2con, TOUTPS0 ); //Set timer 2 mode (enable or disable) clear_bit( t2con, TMR2ON ); //enable timer 2 //Enable interrupts (Timer0) intcon = 0xA0; short resval; lcd_setup(); lprintf( "BootUp...\n" ); delay_ms( 2000000 ); //Endless loop while( 1 ){ adcon0 = 10000001b; // Read from AN0 delay_us(20); set_bit(adcon0, 2); // INNER GATES while (A2D_not_done); // Wait for a2d done flag to change resval = adresh; lcd_clear(); if(resval >1)lprintf(">0"); if(resval <1)lprintf("<0"); delay_ms( 1000000 ); } } Best Reguards J3n4
  6. Sorry i tryed the same process after reinstalling the program and now it work. Sorry again. Please help me, i need to make the same with the pic 16f876 where i can faund or search example for do it? Its most important for me. Txn! Reguards j3n4
  7. Move forward one step at a time and you will find it.Watch out as some pics use Port A for analog inputs, and that is the default mode for the port. Regards Dave <{POST_SNAPBACK}> Ok, right. But i have make new empty project, selected 16F84A the pic target and selected the clock at 20000000. I have copy and past the source code, build all and not work. What I lost? If i know this i think i can make the same for other pics... or not? In any case Tnx for your Help Dave! Reguards j34n
  8. Yes RA1 is the same as RA01. Select the pin from the drop down list in each case instead of typing the pin name in. Please run the original project with all original configuration, as that will definately work. You can re-install the SourceBoost package to restore all source and project files (the project file actually contains the plugin configuration). Regards Dave <{POST_SNAPBACK}> Ok i have deinstalled and reinstalled it, i start the original project from the example code and its work!!! But whyy!?? Please tell me why! I need for my project! Reguards j3n4
  9. Its most like a configuration problem in the LCD config. Like you have connected it to the correct PIC i/o pins. BTW: Your english is very good. Regards Dave <{POST_SNAPBACK}> Hi, the only difference on my IDE is the 16f876 pic and the clock frequence at 4000000. But i have just tested with 16f84A and 20000000 clock frequence and not working too! :-( The Pin i have found in source code is the same of plugin: // Date 4 September 2003 // // Designed and test for 16F84A // // Interface : // RS = RA01 // WR = RA02 // E = RA00 // // DB7 = RB07 // DB6 = RB06 // DB5 = RB05 // DB4 = RB04 // // Using 4 Bit interface Plugin can select RA1 instead RA01, is the same? Tnx!! :-) Reguards j3n4 <{POST_SNAPBACK}> I have deinstalled clean directory and reinstalled the sourceboost program... nothing... not work :-((((((
  10. Its most like a configuration problem in the LCD config. Like you have connected it to the correct PIC i/o pins. BTW: Your english is very good. Regards Dave <{POST_SNAPBACK}> Hi, the only difference on my IDE is the 16f876 pic and the clock frequence at 4000000. But i have just tested with 16f84A and 20000000 clock frequence and not working too! :-( The Pin i have found in source code is the same of plugin: // Date 4 September 2003 // // Designed and test for 16F84A // // Interface : // RS = RA01 // WR = RA02 // E = RA00 // // DB7 = RB07 // DB6 = RB06 // DB5 = RB05 // DB4 = RB04 // // Using 4 Bit interface Plugin can select RA1 instead RA01, is the same? Tnx!! :-) Reguards j3n4
  11. Sorry but in all my test i have already selected the LCD plugin, configured it and pressed F5 or the bug icon. The code is the example from: SourceBoost\plugin_examples\lcd\LCD4BIT.__c But the LCD module is not printing. This is the problem. After this testing i wrote here because I have thinked the simulator is an external program... Its platform problem? Can I send screenshot? Reguards j3n4 (Sorry for my english, Im italian).
  12. Compile and link your code (use the build button), then press the bug button on the tool bar. Regards Dave <{POST_SNAPBACK}> Hi, i have already tryed to start debugger for simulate but he show me a green line on the code and the LCD not start. Why? I have copy and past the example found in: SourceBoost\plugin_examples\lcd\LCD4BIT.__c
  13. I have bought a plugin licence but i cannot use it. Please tell me how to start the simulator. :-( Best Regards j3n4 the noob :-(
×
×
  • Create New...