Jump to content

dersk

EstablishedMember
  • Content Count

    12
  • Joined

  • Last visited

Everything posted by dersk

  1. That's what I needed - a driver chip - thanks for all the suggestions, I got it to work.
  2. I'm using the PIC16F913, which has a serial output. I set up the serial port to transmit on a timer overflow interrupt. To send serial data, all I have to do is set TXREG equal to the byte I want to send, right? I've set this up with 2 different compilers, 3 different serial port readers, 3 different baud rates, and I keep getting the same results - serial data is transmitted, but it's not what I sent. In the code snippets below, I send 0x39, but what I get is 0x63 (or ASCII "c" for hyperterm). The data that I get on the serial port is consistent, but never the same as what I send - it's not shifted or inverted. Not sure what the issue is - anyone have any ideas? Thanks! txsta = 0b00100000; rcsta = 0b10000000; spbrg = 0b00001100; //Baud: 1200 ... txreg = 0x39;
  3. So... 12 bit instructions are off the table? No plans to ever add them? I was interested in using the 16F526, but it looks like it has 12 bit instructions.
  4. Is there a compiler problem with the 16F882? I'm trying to use it, but am getting nowhere and I'm not sure if it's the programmer or the compiler. This is the code I'm using to test the chip - compiles fine, programs fine, but produces no output, all ports except Vdd are 0. #include <system.h> #pragma DATA _CONFIG, _MCLRE_OFF & _WDT_OFF & _INTOSC & _PWRTE_OFF & _LVP_OFF void main() { trisa = 0b00000000; trisb = 0b00000000; trisc = 0b00000000; porta = 0b11111111; portb = 0b11111111; portc = 0b11111111; ansel = 0b00000000; anselh = 0b00000000; while(1) { portb.5 = 1; } }
  5. This is a strange problem - I have an ADC interrupt that works fine when using Frc, the dedicated ADC oscillator, as long as internal oscillator frequency operates at 2, 4, or 8MHz. Below 2MHz, the program freezes, but only when using Frc. The other ADC clock sources work fine. Anyone have any ideas? Thanks!
  6. I'm having some issues with timer0 (using 16F677). I WAS trying to increase the frequency of timer0, because it wasn't Fosc/4 (internal frequency = 8MHz, no prescalar) as advertised. When I tested the output, each bit of timer0 seemed to have it's own agenda, operating at approximately these frequencies: tmr0.0: 1.8kHz tmr0.1: 1.5kHz tmr0.2: 40kHz tmr0.3: 20kHz tmr0.4: 27kHz tmr0.5: 1.8kHz tmr0.6: 1.8kHz tmr0.7: 1.8kHz I set up the code below and simulated it in SourceBoost with the HEX output set to port C, but it didn't count in any conventional manner. Anyone have any idea what's going on? I tried switching out the MCU, but that didn't help. #include <system.h> #pragma DATA _CONFIG, _MCLRE_OFF & _WDT_OFF & _INTOSC & _PWRTE_OFF #pragma CLOCK_FREQ 8000000 void main() { option_reg = 0b00001000; intcon.7 = 0; trisc = 0b00000000; anselh = 0b00000000; ansel = 0b00000011; portc = 0b00000000; tmr0 = 0; while(1) { portc.0 = tmr0.0; portc.1 = tmr0.1; portc.2 = tmr0.2; portc.3 = tmr0.3; portc.4 = tmr0.4; portc.5 = tmr0.5; portc.6 = tmr0.6; portc.7 = tmr0.7; } }
  7. Anyone have a good boost converter they'd like to share? I'm trying to boost between 1.5V and 3V up to 9V. Thanks
  8. Also, do you need to disable and re-enable interrupts in the interrupt? I thought that was done automatically. Let me know if I'm wrong on that count, but my interrupts work fine without the manual disable, re-enable. Can't help on the I2C, I'm struggling on that myself.
  9. I've tried to adapt a variety of different I2C protocols, but so far none of them have worked. Is there a way to know whether I am on the right track? Usually the code halts once it hits anything with i2c in it.
  10. Has anyone mapped the i2c_driver.h to the 16F677? I'm having some trouble - I pasted below some of the code from the header. In the 16F677, there's only one SSPCON and there's no BCLIF. I've been going through and deleting references to them - is there an easier way? The references to SSPCON2 and BCLIF are numerous and I'm not sure it'll work when I'm done. Is there a way to assign them dummy values? Thanks for any help. //////////////////////////////////////////////////////////////////////////// // i2c hardwareware implementation template arguments //////////////////////////////////////////////////////////////////////////// #define i2c_ARGS 3, PORTC, TRISC, 4, PORTC, TRISC, e_SSPCON1, e_SSPCON2, \ e_SSPSTAT, e_SSPBUF, e_SSPIF_BIT, e_SSPIF_PIR, \ e_BCLIF_BIT, e_BCLIF_PIR, 7, e_SSPADD, (i2c_reset_wdt | i2c_SMP |i2c_HW) // variables cannot be passed as template arguments. The following constants map to // the PIC registers and PIC's i2c register locations. These constants are // then used by the templated functions. #define PORTC 0x0f82 #define TRISC 0x0f94 #define e_SSPCON1 0xfc6 #define e_SSPCON2 0xfc5 #define e_SSPSTAT 0xfc7 #define e_SSPADD 0xfc8 #define e_SSPBUF 0xfc9 #define e_SSPIF_PIR 0xf9e #define e_BCLIF_PIR 0xfa1 #define e_SSPIF_BIT 3 #define e_BCLIF_BIT 3 The code now looks like: //////////////////////////////////////////////////////////////////////////// // i2c hardwareware implementation template arguments //////////////////////////////////////////////////////////////////////////// #define i2c_ARGS 6, e_MSSP_PORT, e_MSSP_TRIS, 4, e_MSSP_PORT, e_MSSP_TRIS, e_SSPCON, \ e_SSPSTAT, e_SSPBUF, e_SSPIF_BIT, e_SSPIF_PIR, \ 7, e_SSPADD, (i2c_reset_wdt | i2c_SMP |i2c_HW) // variables cannot be passed as template arguments. The following constants map to // the PIC registers and PIC's i2c register locations. These constants are // then used by the templated functions. #define e_MSSP_PORT PORTB #define e_MSSP_TRIS TRISB #define e_SSPCON 0x014 #define e_SSPSTAT 0x094 #define e_SSPADD 0x093 #define e_SSPBUF 0x013 #define e_SSPIF_PIR 0x00c #define e_SSPIF_BIT 3
  11. I have been reading that BoostC has one interrupt - is it the same with other PIC compilers? If I were to code in ASM, would I be able to use multiple interrupts? Or is the single interrupt scheme peculiar to the PICs? Thanks.
×
×
  • Create New...